Created
August 10, 2012 10:36
-
-
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
This file contains 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
// 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