Skip to content

Instantly share code, notes, and snippets.

@lennym
Last active August 29, 2015 14:21
Show Gist options
  • Save lennym/e1b063d40e94027b84fb to your computer and use it in GitHub Desktop.
Save lennym/e1b063d40e94027b84fb to your computer and use it in GitHub Desktop.
url normalisation middleware
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