File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 2424 * - pathInfo: /pathinfo/ (additional path information)
2525 *
2626 * @property string $scriptPath
27+ * @property-read string $relativePath
2728 * @property-read string $pathInfo
2829 */
2930class UrlScript extends Url
@@ -59,6 +60,12 @@ public function getScriptPath(): string
5960 }
6061
6162
63+ public function getRelativePath (): string
64+ {
65+ return substr ($ this ->getPath (), strrpos ($ this ->scriptPath , '/ ' ) + 1 );
66+ }
67+
68+
6269 /**
6370 * Returns the base-path.
6471 */
Original file line number Diff line number Diff line change @@ -23,3 +23,21 @@ Assert::same('/test/', $url->basePath);
2323Assert::same ('?q=search ' , $ url ->relativeUrl );
2424Assert::same ('' , $ url ->pathInfo );
2525Assert::same ('http://nette.org:8080/test/?q=search ' , $ url ->absoluteUrl );
26+
27+
28+ $ url = new UrlScript ('http://nette.org:8080/www/about ' );
29+ $ url ->scriptPath = '/www/ ' ;
30+
31+ Assert::same ('/www/about ' , $ url ->path );
32+ Assert::same ('/www/ ' , $ url ->scriptPath );
33+ Assert::same ('about ' , $ url ->relativePath );
34+ Assert::same ('about ' , $ url ->pathInfo );
35+
36+
37+ $ url = new UrlScript ('http://nette.org:8080/www/index.php ' );
38+ $ url ->scriptPath = '/www/index.php ' ;
39+
40+ Assert::same ('/www/index.php ' , $ url ->path );
41+ Assert::same ('/www/index.php ' , $ url ->scriptPath );
42+ Assert::same ('index.php ' , $ url ->relativePath );
43+ Assert::same ('' , $ url ->pathInfo );
You can’t perform that action at this time.
0 commit comments