Merge pull request #1728 from mjbshaw/clean-admin-regex

Don't use unnecessary (and unescaped) regex
This commit is contained in:
Hannah Wolfe 2013-12-22 07:46:31 -08:00
commit bc29b14cde

View File

@ -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');