From 7ee3235a688428a8eb83af5278ffb2daaa370e86 Mon Sep 17 00:00:00 2001 From: Michael Bradshaw Date: Sat, 21 Dec 2013 14:15:22 -0700 Subject: [PATCH] Don't use unnecessary (and unescaped) regex closes #1731 --- core/server/middleware/index.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/core/server/middleware/index.js b/core/server/middleware/index.js index c3f78b09c8..368b4a7413 100644 --- a/core/server/middleware/index.js +++ b/core/server/middleware/index.js @@ -118,12 +118,7 @@ function activateTheme(activeTheme) { // Uses the URL to detect whether this response should be an admin response // This is used to ensure the right content is served, and is not for security purposes function manageAdminAndTheme(req, res, next) { - // TODO improve this regex - if (config.paths().path === '/') { - res.isAdmin = /(^\/ghost\/)/.test(req.url); - } else { - res.isAdmin = new RegExp("^\\" + config.paths().path + "\\/ghost\\/").test(req.url); - } + res.isAdmin = req.url.lastIndexOf(config.paths().webroot + '/ghost/', 0) === 0; if (res.isAdmin) { expressServer.enable('admin');