From da85fee46126db2b897983c515f732ce662be0cc Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Tue, 25 Apr 2017 21:36:30 -0400 Subject: [PATCH 1/4] No change - using "bar" intead of foo 2 times for clarity --- .../Component/Asset/Tests/PathPackageTest.php | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/Symfony/Component/Asset/Tests/PathPackageTest.php b/src/Symfony/Component/Asset/Tests/PathPackageTest.php index a1ac26442a066..be67212ca1788 100644 --- a/src/Symfony/Component/Asset/Tests/PathPackageTest.php +++ b/src/Symfony/Component/Asset/Tests/PathPackageTest.php @@ -35,16 +35,16 @@ public function getConfigs() array('', '', '/foo', '/foo?v1'), - array('/foo', '', '/foo', '/foo/foo?v1'), - array('/foo', '', 'foo', '/foo/foo?v1'), - array('foo', '', 'foo', '/foo/foo?v1'), - array('foo/', '', 'foo', '/foo/foo?v1'), - array('/foo/', '', 'foo', '/foo/foo?v1'), - - array('/foo', 'version-%2$s/%1$s', '/foo', '/foo/version-v1/foo'), - array('/foo', 'version-%2$s/%1$s', 'foo', '/foo/version-v1/foo'), - array('/foo', 'version-%2$s/%1$s', 'foo/', '/foo/version-v1/foo/'), - array('/foo', 'version-%2$s/%1$s', '/foo/', '/foo/version-v1/foo/'), + array('/foo', '', '/bar', '/foo/bar?v1'), + array('/foo', '', 'bar', '/foo/bar?v1'), + array('foo', '', 'bar', '/foo/bar?v1'), + array('foo/', '', 'bar', '/foo/bar?v1'), + array('/foo/', '', 'bar', '/foo/bar?v1'), + + array('/foo', 'version-%2$s/%1$s', '/bar', '/foo/version-v1/bar'), + array('/foo', 'version-%2$s/%1$s', 'bar', '/foo/version-v1/bar'), + array('/foo', 'version-%2$s/%1$s', 'bar/', '/foo/version-v1/bar/'), + array('/foo', 'version-%2$s/%1$s', '/bar/', '/foo/version-v1/bar/'), ); } @@ -61,17 +61,17 @@ public function testGetUrlWithContext($basePathRequest, $basePath, $format, $pat public function getContextConfigs() { return array( - array('', '/foo', '', '/foo', '/foo/foo?v1'), - array('', '/foo', '', 'foo', '/foo/foo?v1'), - array('', 'foo', '', 'foo', '/foo/foo?v1'), - array('', 'foo/', '', 'foo', '/foo/foo?v1'), - array('', '/foo/', '', 'foo', '/foo/foo?v1'), - - array('/bar', '/foo', '', '/foo', '/bar/foo/foo?v1'), - array('/bar', '/foo', '', 'foo', '/bar/foo/foo?v1'), - array('/bar', 'foo', '', 'foo', '/bar/foo/foo?v1'), - array('/bar', 'foo/', '', 'foo', '/bar/foo/foo?v1'), - array('/bar', '/foo/', '', 'foo', '/bar/foo/foo?v1'), + array('', '/foo', '', '/baz', '/foo/baz?v1'), + array('', '/foo', '', 'baz', '/foo/baz?v1'), + array('', 'foo', '', 'baz', '/foo/baz?v1'), + array('', 'foo/', '', 'baz', '/foo/baz?v1'), + array('', '/foo/', '', 'baz', '/foo/baz?v1'), + + array('/bar', '/foo', '', '/baz', '/bar/foo/baz?v1'), + array('/bar', '/foo', '', 'baz', '/bar/foo/baz?v1'), + array('/bar', 'foo', '', 'baz', '/bar/foo/baz?v1'), + array('/bar', 'foo/', '', 'baz', '/bar/foo/baz?v1'), + array('/bar', '/foo/', '', 'baz', '/bar/foo/baz?v1'), ); } From 91664fe2bcbc0f834100cf87747f75e2d5c022a0 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Tue, 25 Apr 2017 21:42:12 -0400 Subject: [PATCH 2/4] Changing behavior back to earlier behavior: an opening / says you do not want path prefixed --- src/Symfony/Component/Asset/PathPackage.php | 2 +- src/Symfony/Component/Asset/Tests/PathPackageTest.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/Asset/PathPackage.php b/src/Symfony/Component/Asset/PathPackage.php index 4dcda08e062c4..ef220a784d130 100644 --- a/src/Symfony/Component/Asset/PathPackage.php +++ b/src/Symfony/Component/Asset/PathPackage.php @@ -58,7 +58,7 @@ public function getUrl($path) $versionedPath = $this->getVersionStrategy()->applyVersion($path); - if ($this->isAbsoluteUrl($versionedPath)) { + if ($this->isAbsoluteUrl($versionedPath) || '/' === substr($versionedPath, 0, 1)) { return $versionedPath; } diff --git a/src/Symfony/Component/Asset/Tests/PathPackageTest.php b/src/Symfony/Component/Asset/Tests/PathPackageTest.php index be67212ca1788..4a9f90df90a11 100644 --- a/src/Symfony/Component/Asset/Tests/PathPackageTest.php +++ b/src/Symfony/Component/Asset/Tests/PathPackageTest.php @@ -35,16 +35,16 @@ public function getConfigs() array('', '', '/foo', '/foo?v1'), - array('/foo', '', '/bar', '/foo/bar?v1'), + array('/foo', '', '/bar', '/bar?v1'), array('/foo', '', 'bar', '/foo/bar?v1'), array('foo', '', 'bar', '/foo/bar?v1'), array('foo/', '', 'bar', '/foo/bar?v1'), array('/foo/', '', 'bar', '/foo/bar?v1'), - array('/foo', 'version-%2$s/%1$s', '/bar', '/foo/version-v1/bar'), + array('/foo', 'version-%2$s/%1$s', '/bar', '/version-v1/bar'), array('/foo', 'version-%2$s/%1$s', 'bar', '/foo/version-v1/bar'), array('/foo', 'version-%2$s/%1$s', 'bar/', '/foo/version-v1/bar/'), - array('/foo', 'version-%2$s/%1$s', '/bar/', '/foo/version-v1/bar/'), + array('/foo', 'version-%2$s/%1$s', '/bar/', '/version-v1/bar/'), ); } @@ -61,13 +61,13 @@ public function testGetUrlWithContext($basePathRequest, $basePath, $format, $pat public function getContextConfigs() { return array( - array('', '/foo', '', '/baz', '/foo/baz?v1'), + array('', '/foo', '', '/baz', '/baz?v1'), array('', '/foo', '', 'baz', '/foo/baz?v1'), array('', 'foo', '', 'baz', '/foo/baz?v1'), array('', 'foo/', '', 'baz', '/foo/baz?v1'), array('', '/foo/', '', 'baz', '/foo/baz?v1'), - array('/bar', '/foo', '', '/baz', '/bar/foo/baz?v1'), + array('/bar', '/foo', '', '/baz', '/baz?v1'), array('/bar', '/foo', '', 'baz', '/bar/foo/baz?v1'), array('/bar', 'foo', '', 'baz', '/bar/foo/baz?v1'), array('/bar', 'foo/', '', 'baz', '/bar/foo/baz?v1'), From b399e98c7e66fdc44c3622dd9fe916526943d4a0 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Thu, 27 Apr 2017 11:18:40 -0400 Subject: [PATCH 3/4] Tweaks thanks to @stloyd --- src/Symfony/Component/Asset/PathPackage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Asset/PathPackage.php b/src/Symfony/Component/Asset/PathPackage.php index ef220a784d130..0d7d16b8c2b7c 100644 --- a/src/Symfony/Component/Asset/PathPackage.php +++ b/src/Symfony/Component/Asset/PathPackage.php @@ -58,7 +58,7 @@ public function getUrl($path) $versionedPath = $this->getVersionStrategy()->applyVersion($path); - if ($this->isAbsoluteUrl($versionedPath) || '/' === substr($versionedPath, 0, 1)) { + if ($this->isAbsoluteUrl($versionedPath) || 0 === strpos($versionedPath, '/')) { return $versionedPath; } From 8fde941b5ec6c041f784792d6e35673564bc7346 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Thu, 27 Apr 2017 18:27:09 -0400 Subject: [PATCH 4/4] Using faster check for opening slash --- src/Symfony/Component/Asset/PathPackage.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Asset/PathPackage.php b/src/Symfony/Component/Asset/PathPackage.php index 0d7d16b8c2b7c..5621986fb58b6 100644 --- a/src/Symfony/Component/Asset/PathPackage.php +++ b/src/Symfony/Component/Asset/PathPackage.php @@ -58,7 +58,8 @@ public function getUrl($path) $versionedPath = $this->getVersionStrategy()->applyVersion($path); - if ($this->isAbsoluteUrl($versionedPath) || 0 === strpos($versionedPath, '/')) { + // if absolute or begins with /, we're done + if ($this->isAbsoluteUrl($versionedPath) || ($versionedPath && '/' === $versionedPath[0])) { return $versionedPath; } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy