Skip to content

Instantly share code, notes, and snippets.

@pirhoo
Created August 10, 2012 10:36
Show Gist options
  • Save pirhoo/3313277 to your computer and use it in GitHub Desktop.
Save pirhoo/3313277 to your computer and use it in GitHub Desktop.
A snippet to remove URL's end slashes on Express Framework, especially for Regex routes
// Put this code where you define your routes on Express Web Framework
// Removes URL's end slashes
app.get(/^(\/(.+))\/$/, function(req, res){
res.redirect(req.params[0]);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment