Skip to content

Commit

Permalink
Merge pull request TryGhost#1728 from mjbshaw/clean-admin-regex
Browse files Browse the repository at this point in the history
Don't use unnecessary (and unescaped) regex
  • Loading branch information
ErisDS committed Dec 22, 2013
2 parents 1018e9a + 7ee3235 commit bc29b14
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions core/server/middleware/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit bc29b14

Please sign in to comment.