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:
@@ -31,6 +31,25 @@ public class IndexHtmlTransformerTests
|
||||
Assert.Equal(Script, IndexHtmlTransformer.Inject(Script));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Inject_LeavesScriptsThatMentionABodyTagAlone()
|
||||
{
|
||||
const string Script = "(self.webpackChunk=self.webpackChunk||[]).push([[17244],{t:\"<div></div></body>\"}]);";
|
||||
|
||||
Assert.Equal(Script, IndexHtmlTransformer.Inject(Script));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Inject_KeepsTagsOtherPluginsAdded()
|
||||
{
|
||||
const string Other = "<script defer src=\"../MediaBar/slideshowpure.js\"></script>";
|
||||
var page = Page.Replace("</body>", Other + "</body>", StringComparison.Ordinal);
|
||||
|
||||
var result = IndexHtmlTransformer.Inject(page);
|
||||
|
||||
Assert.Contains(Other + IndexHtmlTransformer.ScriptTag + "</body>", result, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Transform_HandlesAnEmptyPayload()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user