Skip to content

Commit

Permalink
[fix] Added an option to allow urls without extensions. Fixes #21
Browse files Browse the repository at this point in the history
  • Loading branch information
3rd-Eden committed Mar 27, 2013
1 parent 3a37e26 commit bde30fe
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ Versions.prototype.allows = function allows(what, req) {

// Don't accept queries without file extensions and ignore blacklisted
// extensions
return req.extension !== ''
return (this.get('force extensions') && req.extension !== '')
&& !~this.get('blacklisted extensions').indexOf(req.extension);

// Does this request allow 304 requests?
Expand Down
18 changes: 18 additions & 0 deletions test/middleware.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,24 @@ describe('version.layer() integration', function () {
done();
});
});

it('doesnt allow files without extensions', function () {
versions.app.request()
.get('/id:home/')
.end(function (get) {
expect(get.statusCode).to.equal(404);
versions.set('force extensions', false);

versions.app.request()
.head('/id:home/img/sprite.png')
.end(function (head) {
versions.set('force extensions', true);
expect(head.statusCode).to.equal(200);

done();
});
});
});
});

it('should cache pull requests in memory');
Expand Down
1 change: 1 addition & 0 deletions versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"cors": "*",
"directory": "",
"expire internal cache": "1 hour",
"force extensions": true,
"log level": "log",
"max age": "30 days",
"origin servers": [],
Expand Down

0 comments on commit bde30fe

Please sign in to comment.