X-Git-Url: https://git.cweiske.de/phancap.git/blobdiff_plain/984db1d7a451dadd76afc0e19438e56e73c7b732..6ec6cc280a3312a755cfa8e8e813b1ac771f13cd:/src/phancap/Config.php diff --git a/src/phancap/Config.php b/src/phancap/Config.php index 1bb4379..5034b0f 100644 --- a/src/phancap/Config.php +++ b/src/phancap/Config.php @@ -118,15 +118,23 @@ class Config . preg_replace('/#.*$/', '', $_SERVER['REQUEST_URI']); } + /** + * @return string Directory of URL without trailing slash, + * and without .phar file + */ protected function getCurrentUrlDir() { $url = $this->getCurrentUrl(); $url = preg_replace('/\?.*$/', '', $url); - if (substr($url, -1) == '/') { - return $url; + if (substr($url, -1) != '/') { + $url = substr($url, 0, -strlen(basename($url)) - 1); + } + if (\Phar::running()) { + //remove .phar file name + $url = substr($url, 0, -strlen(basename($url)) - 1); } - return substr($url, 0, -strlen(basename($url)) - 1); + return $url; } } ?>