]> Raphaël G. Git Repositories - packbundle/commitdiff
Make /Resources part from asset path optional
authorRaphaël Gertz <git@rapsys.eu>
Tue, 14 Oct 2025 10:41:45 +0000 (12:41 +0200)
committerRaphaël Gertz <git@rapsys.eu>
Tue, 14 Oct 2025 10:41:45 +0000 (12:41 +0200)
Package/PathPackage.php

index c53b10fc268c74ef7fc179592db25c2ca2b47709..d5b4b6f04c1b7998a43656732996e2e682eacb7a 100644 (file)
@@ -61,7 +61,7 @@ class PathPackage extends Package {
         *
         * Returns an absolute or root-relative public path
         *
         *
         * Returns an absolute or root-relative public path
         *
-        * Transform @BundleBundle to bundle and remove /Resources/public fragment from path
+        * Transform @BundleBundle to bundle and remove [/Resources|]/public fragment from path
         * This bundle name conversion and bundle prefix are the same as in asset:install command
         *
         * @link https://symfony.com/doc/current/bundles.html#overridding-the-bundle-directory-structure
         * This bundle name conversion and bundle prefix are the same as in asset:install command
         *
         * @link https://symfony.com/doc/current/bundles.html#overridding-the-bundle-directory-structure
@@ -70,7 +70,7 @@ class PathPackage extends Package {
         */
        public function getUrl(string $path): string {
                //Match url starting with a bundle name
         */
        public function getUrl(string $path): string {
                //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