From c2ec2d9da9cb39b9d4239ee12b098f89431c2bef Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Mon, 26 Nov 2018 16:26:21 +0100 Subject: [PATCH 1/2] Document encoded forward slashes --- routing.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/routing.md b/routing.md index 9eafe2a93be..7df7d5b1a92 100644 --- a/routing.md +++ b/routing.md @@ -160,6 +160,17 @@ Once the pattern has been defined, it is automatically applied to all routes usi // Only executed if {id} is numeric... }); + +#### Encoded Forward Slashes + +By default, the Laravel routing component allows all characters except `/`. You must explicitly allow `/` to be part of your placeholder by specifying it with a `where` condition: + + Route::get('search/{search}', function ($search) { + return $search; + })->where('search', '.*'); + +Now when you submit a search with an encoded forward slash, it'll be decoded in the `$search` parameter. + ## Named Routes From 3942e8fcf0ddeda273f90103b427cd0c50e7989a Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Mon, 26 Nov 2018 18:58:39 +0100 Subject: [PATCH 2/2] Add note about last route segment --- routing.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/routing.md b/routing.md index 7df7d5b1a92..aaa5bd488c1 100644 --- a/routing.md +++ b/routing.md @@ -171,6 +171,8 @@ By default, the Laravel routing component allows all characters except `/`. You Now when you submit a search with an encoded forward slash, it'll be decoded in the `$search` parameter. +> {note} Please note that using encoded forward slashes is only possible for the last route segment. + ## Named Routes