Skip to content

Commit

Permalink
test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverryan committed Apr 26, 2020
1 parent dc091dc commit 9f254e9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"symfony/config": "^3.4 || ^4.0 || ^5.0",
"symfony/dependency-injection": "^3.4 || ^4.0 || ^5.0",
"symfony/http-kernel": "^3.4 || ^4.0 || ^5.0",
"symfony/polyfill-php80": "^1.15",
"symfony/service-contracts": "^1.0 || ^2.0"
},
"require-dev": {
Expand Down
7 changes: 6 additions & 1 deletion src/Asset/BuildFileLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function findFile(string $path, string $buildName = '_default'): string
}

// sanity / security check
if (!str_ends_with($path, '.css') && !str_ends_with($path, '.js')) {
if (!$this->strEndsWith($path, '.css') && !$this->strEndsWith($path, '.js')) {
throw new \InvalidArgumentException('Can only read files ending in .css and .js');
}

Expand Down Expand Up @@ -81,6 +81,11 @@ private function combinePaths(string $buildPath, string $path): string
return $buildPathInfo->getPathname().'/'.implode('/', $pathParts);
}

private function strEndsWith(string $haystack, string $needle): bool
{
return '' === $needle || $needle === \substr($haystack, -\strlen($needle));
}

/**
* @internal
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/Asset/EntrypointLookupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function testGetJavaScriptFilesWithFileTrackingDisabled()
$this->assertEquals(
['file1.js', 'file3.js'],
$this->entrypointLookup->getJavaScriptFiles('other_entry'),
'file1.js is returned even though it was also returned above',
'file1.js is returned even though it was also returned above'
);

$this->assertEquals(
Expand Down

0 comments on commit 9f254e9

Please sign in to comment.