diff --git a/src/Core/Manifest/ModuleResourceLoader.php b/src/Core/Manifest/ModuleResourceLoader.php index 034bcc6d7..245b7b7c3 100644 --- a/src/Core/Manifest/ModuleResourceLoader.php +++ b/src/Core/Manifest/ModuleResourceLoader.php @@ -84,7 +84,7 @@ class ModuleResourceLoader implements TemplateGlobalProvider protected function resolveModuleResource($resource) { // String of the form vendor/package:resource. Excludes "http://bla" as that's an absolute URL - if (!preg_match('#(?[^/: ]*/[^/: ]*) *: *(?[^ ]*)#', $resource, $matches)) { + if (!preg_match('#^ *(?[^/: ]+/[^/: ]+) *: *(?[^ ]*)$#', $resource, $matches)) { return null; } $module = $matches['module']; diff --git a/tests/php/View/RequirementsTest.php b/tests/php/View/RequirementsTest.php index 8106d5ee9..6001322fc 100644 --- a/tests/php/View/RequirementsTest.php +++ b/tests/php/View/RequirementsTest.php @@ -818,20 +818,19 @@ class RequirementsTest extends SapphireTest public function testCommentedOutScriptTagIsIgnored() { /// Disable nonce - Injector::inst()->registerService(new SimpleResourceURLGenerator(), ResourceURLGenerator::class); + $urlGenerator = new SimpleResourceURLGenerator(); + Injector::inst()->registerService($urlGenerator, ResourceURLGenerator::class); $template = '' . '

more content

'; - /** - * @var Requirements_Backend $backend -*/ + /** @var Requirements_Backend $backend */ $backend = Injector::inst()->create(Requirements_Backend::class); $this->setupRequirements($backend); $src = $this->getThemeRoot() . '/javascript/RequirementsTest_a.js'; - $urlSrc = Controller::join_links(Director::baseURL(), $src); $backend->javascript($src); $html = $backend->includeInHTML($template); + $urlSrc = $urlGenerator->urlForResource($src); $this->assertEquals( '' . '

more content