Skip to content

Commit 0c88d13

Browse files
committed
fix: bug au niveau du fileviewer
impossible de charger une page normale qui n'est pas un fichier uploadé
1 parent 9dd9d31 commit 0c88d13

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/Middlewares/FileViewer.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,20 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
4646
}
4747

4848
$path = trim(urldecode($request->getPath()), '/');
49-
[$prefix, $this->path] = explode('/', $path, 2);
49+
[$prefix, $this->path] = explode('/', $path, 2) + [1 => ''];
50+
$prefix = trim($prefix, '/');
51+
$this->path = trim($this->path, '/');
5052

5153
foreach ($config['disks'] as $name => $disk) {
52-
if (str_ends_with(trim($disk['url'], '/'), trim($prefix, '/'))) {
54+
$url = trim($disk['url'] ?? '', '/');
55+
56+
if (str_ends_with($url, $prefix)) {
5357
$this->disk = $this->filesystem->disk($name); // @phpstan-ignore-line
5458
break;
5559
}
5660
}
5761

58-
if (null === $this->disk) {
62+
if (null === $this->disk || '' === $this->path) {
5963
return $handler->handle($request);
6064
}
6165

0 commit comments

Comments
 (0)