Skip to content

Commit 6748471

Browse files
committed
fix: redirect to default page on 404
1 parent 4fde140 commit 6748471

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Web/Documentation/DocumentationController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
use Tempest\Support\Str\ImmutableString;
1616
use Tempest\View\View;
1717

18+
use function Tempest\Router\uri;
1819
use function Tempest\Support\arr;
1920
use function Tempest\Support\Str\before_first;
20-
use function Tempest\Router\uri;
2121

2222
final readonly class DocumentationController
2323
{
@@ -36,7 +36,7 @@ public function redirect(string $path): Redirect
3636
#[Get('/{version}')]
3737
public function index(?string $version): Redirect
3838
{
39-
$version = Version::tryFromString($version);
39+
$version = Version::tryFromString($version) ?? Version::default();
4040

4141
$category = arr(glob(__DIR__ . "/content/{$version->getUrlSegment()}/*", flags: GLOB_ONLYDIR))
4242
->tap(fn (ImmutableArray $files) => $files->isEmpty() ? throw new RuntimeException('Documentation has not been fetched. Run `tempest docs:pull`.') : null)

0 commit comments

Comments
 (0)