diff --git a/app/resources/js/components/file-info-modal.vue b/app/resources/js/components/file-info-modal.vue index 44928ac..f86eb79 100644 --- a/app/resources/js/components/file-info-modal.vue +++ b/app/resources/js/components/file-info-modal.vue @@ -56,9 +56,6 @@ }; }, computed: { - baseHref() { - return document.getElementsByTagName('base')[0].href; - }, styles() { return { 'hidden': ! this.visible }; }, @@ -71,7 +68,7 @@ this.filePath = filePath; this.visible = true; - await axios.get(this.baseHref + 'file-info/' + filePath).then(function (response) { + await axios.get('?info=' + filePath).then(function (response) { this.hashes = response.data.hashes; this.loading = false; }.bind(this)).catch( diff --git a/app/src/ViewFunctions/Asset.php b/app/src/ViewFunctions/Asset.php index 4d2f2c6..6dca4d6 100644 --- a/app/src/ViewFunctions/Asset.php +++ b/app/src/ViewFunctions/Asset.php @@ -5,7 +5,7 @@ namespace App\ViewFunctions; class Asset extends ViewFunction { /** @const Constant description */ - protected const ASSET_PATH = '/app/assets/'; + protected const ASSET_PATH = 'app/assets/'; /** @var string The function name */ protected $name = 'asset'; @@ -19,8 +19,6 @@ class Asset extends ViewFunction */ public function __invoke(string $path): string { - $assetPath = dirname($_SERVER['SCRIPT_NAME']) . self::ASSET_PATH . ltrim($path, '/'); - - return '/' . ltrim($assetPath, '/'); + return self::ASSET_PATH . ltrim($path, '/'); } } diff --git a/app/src/ViewFunctions/Breadcrumbs.php b/app/src/ViewFunctions/Breadcrumbs.php index 3989dd1..c1809bd 100644 --- a/app/src/ViewFunctions/Breadcrumbs.php +++ b/app/src/ViewFunctions/Breadcrumbs.php @@ -25,9 +25,9 @@ class Breadcrumbs extends ViewFunction return $breadcrumbs->filter(function (string $crumb) { return $crumb !== '.'; })->reduce(function (Collection $carry, string $crumb) { - return $carry->put($crumb, $carry->last() . '/' . $crumb); - }, new Collection)->map(function (string $path) { - return '/' . ltrim(dirname($_SERVER['SCRIPT_NAME']) . $path, '/'); + return $carry->put($crumb, ltrim("{$carry->last()}/{$crumb}", '/')); + }, new Collection)->map(function (string $path): string { + return sprintf('?dir=%s', $path); }); } } diff --git a/app/src/ViewFunctions/ParentDir.php b/app/src/ViewFunctions/ParentDir.php index a90bb48..a5019dd 100644 --- a/app/src/ViewFunctions/ParentDir.php +++ b/app/src/ViewFunctions/ParentDir.php @@ -18,10 +18,10 @@ class ParentDir extends ViewFunction */ public function __invoke(string $path) { - $parentDir = dirname($_SERVER['SCRIPT_NAME']) . '/' . Collection::make( + $parentDir = Collection::make( explode('/', $path) )->filter()->slice(0, -1)->implode('/'); - return '/' . ltrim($parentDir, '/'); + return empty($parentDir) ? '' : sprintf('?dir=%s', $parentDir); } } diff --git a/app/src/ViewFunctions/Url.php b/app/src/ViewFunctions/Url.php index 41586ff..4a5883d 100644 --- a/app/src/ViewFunctions/Url.php +++ b/app/src/ViewFunctions/Url.php @@ -14,10 +14,10 @@ class Url extends ViewFunction * * @return string */ - public function __invoke(string $path): string + public function __invoke(string $path = '/'): string { - $url = dirname($_SERVER['SCRIPT_NAME']) . '/' . ltrim($path, '/'); + $path = preg_replace('/^[.\/]+/', '', $path); - return '/' . trim($url, '/'); + return empty($path) ? '' : sprintf('?dir=%s', ltrim($path, './')); } } diff --git a/app/views/components/header.twig b/app/views/components/header.twig index 74c182c..91090f6 100644 --- a/app/views/components/header.twig +++ b/app/views/components/header.twig @@ -1,7 +1,7 @@