diff --git a/src/View/CSPBackend.php b/src/View/CSPBackend.php index df3b5cc..b9540cf 100644 --- a/src/View/CSPBackend.php +++ b/src/View/CSPBackend.php @@ -246,18 +246,7 @@ public function includeInHTML($content): string } $requirements = $this->createHeadTags($requirements); - - // Inject CSS into body - $content = $this->insertTagsIntoHead($requirements, $content); - - // Inject scripts - if ($this->getForceJSToBottom()) { - $content = $this->insertScriptsAtBottom($jsRequirements, $content); - } elseif ($this->getWriteJavascriptToBody()) { - $content = $this->insertScriptsIntoBody($jsRequirements, $content); - } else { - $content = $this->insertTagsIntoHead($jsRequirements, $content); - } + $content = $this->insertContent($content, $requirements, $jsRequirements); return $content; } @@ -331,4 +320,27 @@ protected function shouldContinue($content): bool return $tagsAvailable && $hasFiles; } + + /** + * @param $content + * @param string $requirements + * @param string $jsRequirements + * @return string + */ + protected function insertContent($content, string $requirements, string $jsRequirements): string + { + // Inject CSS into head + $content = $this->insertTagsIntoHead($requirements, $content); + + // Inject scripts + if ($this->getForceJSToBottom()) { + $content = $this->insertScriptsAtBottom($jsRequirements, $content); + } elseif ($this->getWriteJavascriptToBody()) { + $content = $this->insertScriptsIntoBody($jsRequirements, $content); + } else { + $content = $this->insertTagsIntoHead($jsRequirements, $content); + } + + return $content; + } }