Skip to content

Commit

Permalink
Fixed absolute path checking on windows. Closes #829 [reported by and…
Browse files Browse the repository at this point in the history
…rewpmckenzie]
  • Loading branch information
tj committed Aug 29, 2011
1 parent 1301098 commit cbf330c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
13 changes: 13 additions & 0 deletions lib/utils.js
Expand Up @@ -5,6 +5,19 @@
* MIT Licensed
*/

/**
* Check if `path` looks absolute.
*
* @param {String} path
* @return {Boolean}
* @api private
*/

exports.isAbsolute = function(path){
if ('/' == path[0]) return true;
if (':' == path[1] && '\\' == path[2]) return true;
};

/**
* Merge object `b` with `a` giving precedence to
* values in object `a`.
Expand Down
3 changes: 2 additions & 1 deletion lib/view/view.js
Expand Up @@ -10,6 +10,7 @@
*/

var path = require('path')
, utils = require('../utils')
, extname = path.extname
, dirname = path.dirname
, basename = path.basename
Expand Down Expand Up @@ -99,7 +100,7 @@ View.prototype.resolvePath = function(){
// Implicit engine
if (!~this.basename.indexOf('.')) path += this.extension;
// Absolute
if ('/' == path[0]) return path;
if (utils.isAbsolute(path)) return path;
// Relative to parent
if (this.relative && this.parent) return this.parent.dirname + '/' + path;
// Relative to root
Expand Down

0 comments on commit cbf330c

Please sign in to comment.