Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[fix] Comparison for urls without extension always failed when 'force…

… extensions' was set to false
  • Loading branch information...
commit d19fe8ab33755a48e185d701d2df8ed2e0a62b08 1 parent bde30fe
@eboskma eboskma authored
Showing with 13 additions and 7 deletions.
  1. +1 −1  index.js
  2. +12 −6 test/middleware.test.js
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 (this.get('force extensions') && req.extension !== '')
+ return ((this.get('force extensions') && req.extension !== '') || !this.get('force extensions'))
&& !~this.get('blacklisted extensions').indexOf(req.extension);
// Does this request allow 304 requests?
View
18 test/middleware.test.js
@@ -276,14 +276,20 @@ describe('version.layer() integration', function () {
done();
});
});
+ });
- it('doesnt allow files without extensions', function () {
+ it('doesnt allow files without extensions', function (done) {
+ versions.app.request()
+ .get('/id:home/')
+ .end(function (get) {
+ expect(get.statusCode).to.equal(404);
+ versions.set('force extensions', false);
+
versions.app.request()
- .get('/id:home/')
- .end(function (get) {
- expect(get.statusCode).to.equal(404);
- versions.set('force extensions', false);
-
+ .head('/id:home/')
+ .end(function (head) {
+ expect(head.statusCode).to.equal(200);
+
versions.app.request()
.head('/id:home/img/sprite.png')
.end(function (head) {
Please sign in to comment.
Something went wrong with that request. Please try again.