From f402760877d251401c9ca64509ab2998cf27fc08 Mon Sep 17 00:00:00 2001 From: nrstott Date: Fri, 13 Sep 2013 15:27:46 -0500 Subject: [PATCH] adds isAbsolute test for view paths in viewEngine --- lib/view.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/view.js b/lib/view.js index ca62441..ec09814 100644 --- a/lib/view.js +++ b/lib/view.js @@ -54,7 +54,7 @@ ViewEngine.prototype.cacheView = function(view) { }; ViewEngine.prototype.read = function(view) { - return readFile(this.viewPath(view), 'utf8'); + return readFile(isAbsolute(view) ? view : this.viewPath(view), 'utf8'); }; ViewEngine.prototype.cache = function(view, str) { @@ -270,6 +270,15 @@ var setting = exports.setting = function(key, val) { return settings[key]; }; +/** + * Returns whether a path is an absolute path. + */ +function isAbsolute(path) { + var windowsDriveRe = /^[a-zA-Z]:/; + + return path[0] === '/' || windowsDriveRe.test(path); +} + /** * Returns a string representation of an object. * This method is used for sharing objects with the client.