fix: register the index.html transformation under the shared pattern
File Transformation only runs the callbacks whose pattern string equals the requested path, so the anchored pattern was skipped whenever another plugin had registered the plain one. Script chunks that match the pattern as a regex are returned unchanged.
This commit is contained in:
@@ -37,7 +37,7 @@ public static class IndexHtmlTransformer
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts the script tag before the closing body tag. Content without one is not a page and is left alone.
|
||||
/// Inserts the script tag before the closing body tag. Anything that is not an HTML page is left alone.
|
||||
/// </summary>
|
||||
/// <param name="html">The page.</param>
|
||||
/// <returns>The page with the script tag.</returns>
|
||||
@@ -50,6 +50,12 @@ public static class IndexHtmlTransformer
|
||||
return html;
|
||||
}
|
||||
|
||||
// File Transformation also hands over script chunks whose name happens to match the pattern.
|
||||
if (!html.Contains("<html", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return html;
|
||||
}
|
||||
|
||||
var index = html.LastIndexOf("</body>", StringComparison.OrdinalIgnoreCase);
|
||||
return index < 0 ? html : html.Insert(index, ScriptTag);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user