wise-web-client
Version:
Based on Spine MVC framework
24 lines (20 loc) • 523 B
JavaScript
var $ = require('./dollar').$;
var doNothing = function(req, res, next) {
next();
};
//redirect "/#abc" to "/abc"
var rewriteUrl = function(req, res, next) {
if (req.url.match(/^\/(?!#)/) && req.url !== '/') {
if (!req.url.match(new RegExp('^\/(font|css|img|js|api|tpl|comp|config)'))) {
var url = req.url.replace(/^\//, "/#").replace(/\/$/, '');
res.redirect(url);
} else {
next();
}
} else {
next();
}
};
//TODO: add logger
var middleware = [rewriteUrl, doNothing];
module.exports = middleware;