Skip to content

Commit

Permalink
View lookup should return something at least
Browse files Browse the repository at this point in the history
Even if the path doesn't exist it's better for the lookup
method to return the last path checked. Without a return
value, if one attempts to render a path that doesn't
exist one gets "TypeError: Bad argument" because the
first param for fs.readFile is undefined. If the path is
returned one gets the more helpful "Error: ENOENT, no
such file or directory" along with the string for the
path.
  • Loading branch information
Gabriel Farrell committed Apr 2, 2012
1 parent e6a15f6 commit fd5127e
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ View.prototype.lookup = function(path){
if (exists(path)) return path;

// <path>/index.<engine>
path = join(dirname(path), basename(path, ext), 'index' + ext);
if (exists(path)) return path;
return join(dirname(path), basename(path, ext), 'index' + ext);
};

/**
Expand Down

0 comments on commit fd5127e

Please sign in to comment.