Middleware to normalize the trailing slash of the uri path
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.
composer require middlewares/trailing-slash
$dispatcher = new Dispatcher([ (new Middlewares\TrailingSlash(true)) ->redirect() ]); $response = $dispatcher->dispatch(new ServerRequest());
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
Set this option to return a
301 response redirecting to the new path
The MIT License (MIT). Please see LICENSE for more information.