fix: Improve routing specificity and add new test.

- Update regular expressions for two routes in `routes/web.php` to match specific numeral values
- Add new test for incorrect URL parsing in `tests/Feature/ArticlesTest.php`
This commit is contained in:
Jonny Barnes 2023-06-16 13:02:00 +01:00
parent 66ed0f5c51
commit d9e2467ba5
Signed by: jonny
SSH key fingerprint: SHA256:CTuSlns5U7qlD9jqHvtnVmfYV3Zwl2Z7WnJ4/dqOaL8
2 changed files with 9 additions and 2 deletions

View file

@ -150,8 +150,8 @@ Route::group(['domain' => config('url.longurl')], function () {
Route::get('/feed.json', [FeedsController::class, 'blogJson']); Route::get('/feed.json', [FeedsController::class, 'blogJson']);
Route::get('/feed.jf2', [FeedsController::class, 'blogJf2']); Route::get('/feed.jf2', [FeedsController::class, 'blogJf2']);
Route::get('/s/{id}', [ArticlesController::class, 'onlyIdInURL']); Route::get('/s/{id}', [ArticlesController::class, 'onlyIdInURL']);
Route::get('/{year?}/{month?}', [ArticlesController::class, 'index']); Route::get('/{year?}/{month?}', [ArticlesController::class, 'index'])->where(['year' => '[0-9]{4}', 'month' => '[0-9]{2}']);
Route::get('/{year}/{month}/{slug}', [ArticlesController::class, 'show']); Route::get('/{year}/{month}/{slug}', [ArticlesController::class, 'show'])->where(['year' => '[0-9]{4}', 'month' => '[0-9]{2}']);
}); });
// Notes pages using NotesController // Notes pages using NotesController

View file

@ -58,4 +58,11 @@ class ArticlesTest extends TestCase
$response = $this->get('/blog/s/22'); $response = $this->get('/blog/s/22');
$response->assertNotFound(); $response->assertNotFound();
} }
/** @test */
public function someUrlsDoNotParseCorrectly(): void
{
$response = $this->get('/blog/feed.js');
$response->assertNotFound();
}
} }