Merge pull request #4611 from sbwalker/dev
fix #4607 - Site HeadContent scripts being added twice
This commit is contained in:
commit
d9759a95eb
|
@ -66,17 +66,18 @@
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(content))
|
if (!string.IsNullOrEmpty(content))
|
||||||
{
|
{
|
||||||
if (PageState.RenderMode == RenderModes.Interactive)
|
var elements = content.Split('<', StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
foreach (var element in elements)
|
||||||
{
|
{
|
||||||
// remove scripts
|
if (PageState.RenderMode == RenderModes.Static || (!element.ToLower().StartsWith("script") && !element.ToLower().StartsWith("/script")))
|
||||||
var index = content.IndexOf("<script");
|
|
||||||
while (index >= 0)
|
|
||||||
{
|
{
|
||||||
content = content.Remove(index, content.IndexOf("</script>") + 9 - index);
|
if (!headcontent.Contains("<" + element) || element.StartsWith("/"))
|
||||||
index = content.IndexOf("<script");
|
{
|
||||||
|
headcontent += "<" + element;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
headcontent += content + "\n";
|
headcontent += "\n";
|
||||||
}
|
}
|
||||||
return headcontent;
|
return headcontent;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user