summaryrefslogtreecommitdiff
path: root/app.js
diff options
context:
space:
mode:
authorCheng-Han, Wu2016-04-20 18:19:11 +0800
committerCheng-Han, Wu2016-04-20 18:19:11 +0800
commitf7b719b21094713b32ff89f913734dd026bd5286 (patch)
tree401c7170bc5fa5e01ee5e5d2bc535313c408bb9c /app.js
parentf6a995143d4ec5d1649ecb7e7678649c1f8449c4 (diff)
Update to redirect url with trailing slashes
Diffstat (limited to 'app.js')
-rw-r--r--app.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/app.js b/app.js
index 6ef6d85e..6fe0f489 100644
--- a/app.js
+++ b/app.js
@@ -149,6 +149,17 @@ passport.deserializeUser(function (id, done) {
});
});
+// redirect url with trailing slashes
+app.use(function(req, res, next) {
+ if ("GET" == req.method && req.path.substr(-1) == '/' && req.path.length > 1) {
+ var query = req.url.slice(req.path.length);
+ console.log(config.serverurl + req.path.slice(0, -1) + query);
+ res.redirect(301, config.serverurl + req.path.slice(0, -1) + query);
+ } else {
+ next();
+ }
+});
+
// routes need sessions
//template files
app.set('views', __dirname + '/public');