Skip to content

Commit 124b1cc

Browse files
committed
Fix issue where first slug was duplicated on fallback routes
1 parent 8085000 commit 124b1cc

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/Middleware/SetLocale.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ protected function getLocaleFromFallbackRoute(\Illuminate\Http\Request $request)
5151
return $omittedLocale;
5252
}
5353

54+
if ( ! $localeIsSupported) {
55+
return null;
56+
}
57+
5458
return $locale;
5559
}
5660

tests/Unit/Macros/LocalizedUrlMacroTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ public function it_returns_a_localized_url_for_a_non_localized_fallback_route_if
463463
'en' => Route::localizedUrl('en'),
464464
'nl' => Route::localizedUrl('nl'),
465465
], 404);
466-
})->name('404');
466+
})->middleware(SetLocale::class)->name('404');
467467

468468
$response = $this->call('GET', '/non/existing/route');
469469
$response->assertNotFound();

0 commit comments

Comments
 (0)