Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Comparison to allow urls without extension always failed #22

Merged
merged 1 commit into from

2 participants

@eboskma

When the option 'force extensions' was set to false, the comparison in #allows always returned false, so it always returned a 404. The tests didn't reflect this, because it was not properly nested.

@3rd-Eden
Owner

Good catch, thanks for pull request. I'll push out a new release this afternoon.

@3rd-Eden 3rd-Eden merged commit a64b911 into from
@eboskma eboskma deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 28, 2013
  1. @eboskma

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

    eboskma authored
    … extensions' was set to false
This page is out of date. Refresh to see the latest.
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) {
Something went wrong with that request. Please try again.