diff --git a/lib/view.js b/lib/view.js index d66b4a2d89c..10d2976f7be 100644 --- a/lib/view.js +++ b/lib/view.js @@ -55,6 +55,10 @@ function View(name, options) { this.defaultEngine = opts.defaultEngine; this.ext = extname(name); this.name = name; + + if (this.ext === '.') { + this.ext = ''; + } this.root = opts.root; if (!this.ext && !this.defaultEngine) { diff --git a/test/app.render.js b/test/app.render.js index bd65ce1035b..7b6724d2994 100644 --- a/test/app.render.js +++ b/test/app.render.js @@ -90,6 +90,18 @@ describe('app', function(){ done(); }); }) + + it('should provide a helpful error when view name ends with a dot', function(done){ + var app = createApp(); + app.set('view engine', 'tmpl'); + + app.set('views', path.join(__dirname, 'fixtures')) + app.render('rawr.', function (err) { + assert.ok(err) + assert.equal(err.message, 'Failed to lookup view "rawr." in views directory "' + path.join(__dirname, 'fixtures') + '"') + done(); + }); + }) }) describe('when an error occurs', function(){