cskr/grasshopper

Requesting http://localhost// (two slashes) causes crash

Closed this issue · 2 comments

I was running this example:

var gh = require('grasshopper');

 gh.get('/', function() {

        this.model['name'] = 'Adam';
        this.render('home');
 });

 gh.serve(80);

Everything works as expected, but if you request http://localhost// instead of http://localhost/ it crashes with this error:

/usr/local/lib/node/.npm/grasshopper/0.2.2/package/lib/renderer.js:100
    if(path.match(/\.[^\/]+$/)) {
            ^
TypeError: Cannot call method 'match' of undefined
    at RequestContext.getExtn (/usr/local/lib/node/.npm/grasshopper/0.2.2/package/lib/renderer.js:100:13)
    at new RequestContext (/usr/local/lib/node/.npm/grasshopper/0.2.2/package/lib/renderer.js:69:22)
    at Object.handleError (/usr/local/lib/node/.npm/grasshopper/0.2.2/package/lib/renderer.js:41:5)
    at Server. (/usr/local/lib/node/.npm/grasshopper/0.2.2/package/lib/grasshopper.js:82:22)
    at Server.emit (events:33:26)
    at HTTPParser.onIncoming (http:829:10)
    at HTTPParser.onHeadersComplete (http:87:31)
    at Stream.ondata (http:761:22)
    at IOWatcher.callback (net:517:29)
    at node.js:267:9
cskr commented

The crash is handled by 3cced8c. It will be available with the 0.2.3 release.

Thanks for reporting.

cskr commented

On further investigation it looks like an issue with node's URL parser and currently affects many other node frameworks too. :(