Skip to content

Commit

Permalink
adds isAbsolute test for view paths in viewEngine
Browse files Browse the repository at this point in the history
  • Loading branch information
nrstott committed Sep 13, 2013
1 parent da9ec4f commit f402760
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/view.js
Expand Up @@ -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) {
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit f402760

Please sign in to comment.