Last active
August 29, 2015 14:21
-
-
Save lennym/e1b063d40e94027b84fb to your computer and use it in GitHub Desktop.
url normalisation middleware
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var url = require('url'); | |
| app.use(function (req, res, next) { | |
| if (req.path.indexOf('&') > -1) { | |
| var path = req.path.split('&')[0]; | |
| res.redirect(url.format({ | |
| pathname: path, | |
| query: req.query | |
| })); | |
| } else { | |
| next(); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment