diff --git a/app/Controllers/MediaController.php b/app/Controllers/MediaController.php index c050bd4..3648796 100644 --- a/app/Controllers/MediaController.php +++ b/app/Controllers/MediaController.php @@ -84,8 +84,8 @@ class MediaController extends Controller 'delete_token' => $token, 'media' => $media, 'type' => $type, - 'url' => urlFor("/{$userCode}/{$mediaCode}"), - 'copy_raw' => $this->getSetting('copy_url_behavior', 'off') === 'raw', + 'url' => urlFor(glue($userCode, $mediaCode)), + 'copy_raw' => $this->session->get('copy_raw', false), ]); } diff --git a/app/Factories/ViewFactory.php b/app/Factories/ViewFactory.php index f20f77d..48ee204 100644 --- a/app/Factories/ViewFactory.php +++ b/app/Factories/ViewFactory.php @@ -42,6 +42,7 @@ class ViewFactory $twig->addFunction(new TwigFunction('inPath', 'inPath')); $twig->addFunction(new TwigFunction('humanFileSize', 'humanFileSize')); $twig->addFunction(new TwigFunction('param', 'param')); + $twig->addFunction(new TwigFunction('glue', 'glue')); return new View($twig); } diff --git a/app/helpers.php b/app/helpers.php index fafee40..a6f850c 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -493,3 +493,14 @@ if (!function_exists('isSecure')) { || (!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] === 443); } } + +if (!function_exists('glue')) { + /** + * @param mixed ...$pieces + * @return string + */ + function glue(...$pieces): string + { + return '/'.implode('/', $pieces); + } +} diff --git a/resources/templates/dashboard/grid.twig b/resources/templates/dashboard/grid.twig index 64cd0f7..718d15f 100644 --- a/resources/templates/dashboard/grid.twig +++ b/resources/templates/dashboard/grid.twig @@ -19,7 +19,7 @@