middlewares/trailing-slash

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

Homepage:

Size: 25

Language: PHP

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

middlewares/trailing-slash

Latest Version on Packagist Software License Build Status Quality Score Total Downloads SensioLabs Insight

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.

Requirements
Installation

This package is installable and autoloadable via Composer as middlewares/trailing-slash.

oser require middlewares/trailing-slash
Example
patcher = new Dispatcher([
(new Middlewares\TrailingSlash(true))
    ->redirect()


ponse = $dispatcher->dispatch(new ServerRequest());
Options
__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.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.