Skip to content

Commit

Permalink
fix path identifications in case of paths that can contain 'index'
Browse files Browse the repository at this point in the history
  • Loading branch information
devel-pa committed Dec 16, 2013
1 parent 7ac3988 commit 2baf449
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/express/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,20 @@ SailsView.prototype.lookup = function(path) {
// <path>.<engine>
if (!utils.isAbsolute(path)) path = join(this.root, path);

//if (exists(path)) return globPath(path)[0];
if (exists (path)) {
return globPath(path)[0];
return globPath(path)[0];
} else {
if(sails.config.modules) {
var fragments = bkpPath.split('/');
if(fragments.length >= 3 && _.indexOf(sails.config.modules.register, fragments[0]) !== -1) {
if(_.indexOf(sails.config.modules.register, fragments[0]) !== -1) {
var fragment = fragments.shift();
var modulePath = join(sails.config.modules.path, fragment, 'views', fragments.join('/'));
if(exists(modulePath)) return globPath(modulePath)[0];
else {
if(fragments.length > 1 && exists(modulePath)) {
return globPath(modulePath)[0];
}
else if(fragments.length > 0) {
modulePath = join(dirname(modulePath), basename(modulePath, ext), 'index' + ext);
if(exists(modulePath)) return globPath(modulePath)[0];
if(exists(modulePath)) return globPath(modulePath)[0];
}
}
}
Expand Down

0 comments on commit 2baf449

Please sign in to comment.