Skip to content

Commit eb79f70

Browse files
authored
Merge pull request #51 from gwicke/wildcard_listings
Fix handling of wildcard route requests ending in slash; v0.5.4
2 parents a0fcb26 + 03aa9c8 commit eb79f70

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

lib/node.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,8 @@ class Node {
6767
if (segment.constructor === String) {
6868
// Fast path
6969
let res = this._children[_keyPrefix + segment];
70-
if (!res && segment !== '') {
71-
// Fall back to the wildcard match, but only if the segment is
72-
// non-empty.
70+
if (!res) {
71+
// Fall back to the wildcard match.
7372
res = this._children['*'];
7473
if (!res && this._children['**']) {
7574
res = this._children['**'];

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "swagger-router",
3-
"version": "0.5.3",
3+
"version": "0.5.4",
44
"description": "An efficient swagger 2 based router with support for multiple APIs. For use in RESTBase.",
55
"main": "index.js",
66
"scripts": {

test/features/router.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,10 @@ var expectations = {
262262
'/en.wikipedia.org/v1/optional/': {
263263
params: {
264264
domain: 'en.wikipedia.org',
265+
path: '',
265266
_ls: []
266267
},
267-
value: null,
268+
value: '/optional/{+path}',
268269
permissions: [],
269270
filters: []
270271
},
@@ -277,6 +278,16 @@ var expectations = {
277278
permissions: [],
278279
filters: []
279280
},
281+
'/en.wikipedia.org/v1/optional/path/': {
282+
value: '/optional/{+path}',
283+
params: {
284+
domain: 'en.wikipedia.org',
285+
path: 'path/',
286+
_ls: []
287+
},
288+
permissions: [],
289+
filters: []
290+
},
280291
'/en.wikipedia.org/v1/optional/path/bits': {
281292
value: '/optional/{+path}',
282293
params: {

0 commit comments

Comments
 (0)