Permalink
Browse files

View lookup should return something at least

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...
1 parent e6a15f6 commit fd5127e6978dee2d174a6f42402a7107ad8d92a0 @gsf gsf committed Apr 2, 2012
Showing with 1 addition and 2 deletions.
  1. +1 −2 lib/view.js
View
3 lib/view.js
@@ -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);
};
/**

0 comments on commit fd5127e

Please sign in to comment.