Uncapitalise middleware should not affect tokens

no issue

- Whilst testing on next, I noticed trying to signup didn't prepopulate email addresses any more, and this is why
This commit is contained in:
Hannah Wolfe 2014-08-26 22:07:03 +01:00
parent 3fec767df7
commit 25ad4b39fd

View File

@ -154,9 +154,16 @@ function redirectToSetup(req, res, next) {
// Detect uppercase in req.path
function uncapitalise(req, res, next) {
if (/[A-Z]/.test(req.path)) {
var pathToTest = req.path,
isSignupOrReset = req.path.match(/(\/ghost\/(signup|reset)\/)/i);
if (isSignupOrReset) {
pathToTest = isSignupOrReset[1];
}
if (/[A-Z]/.test(pathToTest)) {
res.set('Cache-Control', 'public, max-age=' + utils.ONE_YEAR_S);
res.redirect(301, req.url.replace(req.path, req.path.toLowerCase()));
res.redirect(301, req.url.replace(pathToTest, pathToTest.toLowerCase()));
} else {
next();
}