Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[fix] Added an option to allow urls without extensions. Fixes #21

  • Loading branch information...
commit bde30fe3e82fb2a7721b81f190335c83aabb493b 1 parent 3a37e26
@3rd-Eden authored
Showing with 20 additions and 1 deletion.
  1. +1 −1  index.js
  2. +18 −0 test/middleware.test.js
  3. +1 −0  versions.json
View
2  index.js
@@ -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?
View
18 test/middleware.test.js
@@ -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');
View
1  versions.json
@@ -5,6 +5,7 @@
"cors": "*",
"directory": "",
"expire internal cache": "1 hour",
+ "force extensions": true,
"log level": "log",
"max age": "30 days",
"origin servers": [],
Please sign in to comment.
Something went wrong with that request. Please try again.