I have the following route in web.php
:
Route::get('posts/{encoded_id}/{slug}', 'PostController@show')
... and it works fine:
http://example.test/posts/1Dl89aRjpk/this-is-some-title
But the "problem" is that it will also work when I add a white space at the end of route parameter {encoded_id}
:
http://example.test/posts/1Dl89aRjpk /this-is-some-title
// or
http://example.test/posts/1Dl89aRjpk%20 /this-is-some-title
// or
http://example.test/posts/1Dl89aRjpk%20%20 /this-is-some-title
With whitespace added at the end - this will work normally and there is no 404:
Post::where('encoded_id', $encoded_id)->firstOrFail();
... but why?
Maybe because of the type of field in the DB (CHAR
)?
$table->char('encoded_id', 10)
Or maybe it has something to to with .htaccess
(I'm using XAMPP / Windows)?
I'm using Laravel 5.6.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire