diff --git a/routes/web.php b/routes/web.php index 35c12d95..e5ace4e1 100644 --- a/routes/web.php +++ b/routes/web.php @@ -150,8 +150,8 @@ Route::group(['domain' => config('url.longurl')], function () { Route::get('/feed.json', [FeedsController::class, 'blogJson']); Route::get('/feed.jf2', [FeedsController::class, 'blogJf2']); Route::get('/s/{id}', [ArticlesController::class, 'onlyIdInURL']); - Route::get('/{year?}/{month?}', [ArticlesController::class, 'index']); - Route::get('/{year}/{month}/{slug}', [ArticlesController::class, 'show']); + Route::get('/{year?}/{month?}', [ArticlesController::class, 'index'])->where(['year' => '[0-9]{4}', 'month' => '[0-9]{2}']); + Route::get('/{year}/{month}/{slug}', [ArticlesController::class, 'show'])->where(['year' => '[0-9]{4}', 'month' => '[0-9]{2}']); }); // Notes pages using NotesController diff --git a/tests/Feature/ArticlesTest.php b/tests/Feature/ArticlesTest.php index 6f1fa474..d268fc4d 100644 --- a/tests/Feature/ArticlesTest.php +++ b/tests/Feature/ArticlesTest.php @@ -58,4 +58,11 @@ class ArticlesTest extends TestCase $response = $this->get('/blog/s/22'); $response->assertNotFound(); } + + /** @test */ + public function someUrlsDoNotParseCorrectly(): void + { + $response = $this->get('/blog/feed.js'); + $response->assertNotFound(); + } }