Name: trailing-slash
Owner: Middlewares
Description: PSR-15 middleware to normalize the trailing slash of the uri path
Created: 2016-09-30 18:22:55.0
Updated: 2018-01-24 21:34:26.0
Pushed: 2018-01-24 21:33:47.0
Size: 25
Language: PHP
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Middleware to normalize the trailing slash of the uri path. By default removes the slash so, for example, /post/23/
is converted to /post/23
. Useful if you have problems with the router.
This package is installable and autoloadable via Composer as middlewares/trailing-slash.
oser require middlewares/trailing-slash
patcher = new Dispatcher([
(new Middlewares\TrailingSlash(true))
->redirect()
ponse = $dispatcher->dispatch(new ServerRequest());
__construct(booll $trailingSlash = false)
Set true
to add the slash instead remove so, for example, post/23
is converted to /post/23/
. Note that if the path contains an extension, the slash is NOT added. For example, images/image.png
remains the same, instead be converted to images/image.png/
.
redirect(true)
Set this option to return a 301
response redirecting to the new path
Please see CHANGELOG for more information about recent changes and CONTRIBUTING for contributing details.
The MIT License (MIT). Please see LICENSE for more information.