]> Raphaël G. Git Repositories - packbundle/commitdiff
Add shortcut @Name internaly fixed to canonical @NameBundle/Resources/public
authorRaphaël Gertz <git@rapsys.eu>
Tue, 26 Nov 2019 20:00:59 +0000 (21:00 +0100)
committerRaphaël Gertz <git@rapsys.eu>
Tue, 26 Nov 2019 20:00:59 +0000 (21:00 +0100)
Fix extra trailing /
Add not about trailing /

Asset/PathPackage.php

index 371ffccf9be42c04d76bebd02258adc564a11724..5fa69e24ef5547be261cc3f5e4cccc660ed0c8b0 100644 (file)
@@ -35,14 +35,15 @@ class PathPackage extends BasePackage {
         */
        public function getUrl($path) {
                //Match url starting with a bundle name
         */
        public function getUrl($path) {
                //Match url starting with a bundle name
-               if (preg_match('%^@([A-Z][a-zA-Z]*)Bundle/Resources/public(/.*)$%', $path, $matches)) {
+               if (preg_match('%^@([A-Z][a-zA-Z]*?)(?:Bundle/Resources/public)?/(.*)$%', $path, $matches)) {
                        //Handle empty or without replacement pattern basePath
                        if (empty($this->basePath) || strpos($this->basePath, '%s') === false) {
                                //Set path from hardcoded format
                        //Handle empty or without replacement pattern basePath
                        if (empty($this->basePath) || strpos($this->basePath, '%s') === false) {
                                //Set path from hardcoded format
-                               $path = '/bundles/'.strtolower($matches[1]).$matches[2];
+                               $path = '/bundles/'.strtolower($matches[1]).'/'.$matches[2];
                        //Proceed with basePath pattern replacement
                        } else {
                                //Set path from basePath pattern
                        //Proceed with basePath pattern replacement
                        } else {
                                //Set path from basePath pattern
+                               //XXX: basePath has a trailing / added by constructor
                                $path = sprintf($this->basePath, strtolower($matches[1])).$matches[2];
                        }
                }
                                $path = sprintf($this->basePath, strtolower($matches[1])).$matches[2];
                        }
                }