You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- [Custom regex for matching parameters](#custom-regex-for-matching-parameters)
44
45
- [Named routes](#named-routes)
45
46
- [Generating URLs To Named Routes](#generating-urls-to-named-routes)
46
47
- [Router groups](#router-groups)
@@ -490,6 +491,28 @@ SimpleRouter::get('/user/{name?}', function ($name = 'Simon') {
490
491
});
491
492
```
492
493
494
+
### Including slash in parameters
495
+
496
+
If you're working with WebDAV services the url could mean the difference between a file and a folder.
497
+
498
+
For instance `/path` will be considered a file - whereas `/path/` will be considered a folder.
499
+
500
+
The router can add the ending slash for the last parameter in your route based on the path. So if `/path/` is requested the parameter will contain the value of `path/` and visa versa.
501
+
502
+
To ensure compatibility with older versions, this feature is disabled by default and has to be enabled by setting
503
+
the `setSettings(['includeSlash' => true])` or by using setting `setSlashParameterEnabled(true)` for your route.
504
+
505
+
**Example**
506
+
507
+
```php
508
+
SimpleRouter::get('/path/{fileOrFolder}', function ($fileOrFolder) {
509
+
return $fileOrFolder;
510
+
})->setSettings(['includeSlash' => true]);
511
+
```
512
+
513
+
- Requesting `/path/file` will return the `$fileOrFolder` value: `file`.
514
+
- Requesting `/path/folder/` will return the `$fileOrFolder` value: `folder/`.
515
+
493
516
### Regular expression constraints
494
517
495
518
You may constrain the format of your route parameters using the where method on a route instance. The where method accepts the name of the parameter and a regular expression defining how the parameter should be constrained:
0 commit comments