Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed extra slash at end of collection bug

  • Loading branch information...
commit 336db7c6170d0124add8bd1f979ceef4bf3da07d 1 parent 578434d
@angelini authored
Showing with 16 additions and 0 deletions.
  1. +5 −0 lib/resty.js
  2. +11 −0 tests/connectIntegration-test.js
View
5 lib/resty.js
@@ -49,6 +49,11 @@ exports.middleware = function resty(resource_dir) {
var components = req.url.split('?')[0].split('/');
components.shift();
+ // Makes '/example/' and '/example' equivalent
+ if(components[components.length - 1] === '') {
+ components.pop();
+ }
+
var context = {
body: req.body,
cookies: req.cookies,
View
11 tests/connectIntegration-test.js
@@ -26,6 +26,17 @@ vows.describe('Using connect').addBatch({
}
},
+ 'testing extra slash on Collection get request': {
+ 'topic': function() {
+ request(BASE_URL + '/users/', this.callback);
+ },
+
+ 'should contain {all: "users"}': function(err, res, body) {
+ assert.isNull(err);
+ assert.equal(JSON.parse(body).all, 'users');
+ }
+ },
+
'testing Resource get request': {
'topic': function() {
request(BASE_URL + '/users/123', this.callback);

0 comments on commit 336db7c

Please sign in to comment.
Something went wrong with that request. Please try again.