@@ -63,8 +63,13 @@ any versioning::
6363
6464 $package = new Package(new EmptyVersionStrategy());
6565
66+ // Absolute path
6667 echo $package->getUrl('/image.png');
6768 // result: /image.png
69+
70+ // Relative path
71+ echo $package->getUrl('image.png');
72+ // result: image.png
6873
6974Packages implement :class: `Symfony\\ Component\\ Asset\\ PackageInterface `,
7075which defines the following two methods:
@@ -105,8 +110,13 @@ suffix to any asset path::
105110
106111 $package = new Package(new StaticVersionStrategy('v1'));
107112
113+ // Absolute path
108114 echo $package->getUrl('/image.png');
109115 // result: /image.png?v1
116+
117+ // Relative path
118+ echo $package->getUrl('image.png');
119+ // result: image.png?v1
110120
111121In case you want to modify the version format, pass a sprintf-compatible format
112122string as the second argument of the ``StaticVersionStrategy `` constructor::
@@ -122,6 +132,9 @@ string as the second argument of the ``StaticVersionStrategy`` constructor::
122132
123133 echo $package->getUrl('/image.png');
124134 // result: /v1/image.png
135+
136+ echo $package->getUrl('image.png');
137+ // result: v1/image.png
125138
126139Custom Version Strategies
127140.........................
@@ -170,6 +183,10 @@ that path over and over again::
170183
171184 echo $package->getUrl('logo.png');
172185 // result: /static/images/logo.png?v1
186+
187+ // Base path is ignored when using absolute paths
188+ echo $package->getUrl('/logo.png');
189+ // result: /logo.png?v1
173190
174191Request Context Aware Assets
175192............................
0 commit comments