Skip to content

Commit

Permalink
Fixed bug with infinite loop
Browse files Browse the repository at this point in the history
  • Loading branch information
evangelion1204 committed Jan 5, 2016
1 parent 8e88a15 commit 990c24d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "radix-tree",
"version": "0.1.3",
"version": "0.1.4",
"description": "Node.js version of a radix tree usable for routers or url path based storage.",
"main": "index.js",
"engines": {
Expand All @@ -22,6 +22,12 @@
"bugs": {
"url": "https://github.com/evangelion1204/radix-tree/issues"
},
"keywords": [
"route",
"routes",
"radix-tree",
"radix"
],
"homepage": "https://github.com/evangelion1204/radix-tree#readme",
"devDependencies": {
"babel-cli": "^6.3.17",
Expand Down
2 changes: 2 additions & 0 deletions src/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ export class Tree {
continue node_loop
}
}

break
}

return undefined
Expand Down
11 changes: 11 additions & 0 deletions test/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,17 @@ describe('Tree', function() {
expect(instance.find('/api/some/path')).to.deep.equal({path: '/api/*api_path', params: {api_path: 'some/path'}})
})

it('non existing paths should return undefined', function () {
let instance = new Tree()

instance.add('/users')
instance.add('/mails')

expect(instance.find('/users')).to.deep.equal({path: '/users'})
expect(instance.find('/mails')).to.deep.equal({path: '/mails'})
expect(instance.find('/another/path')).to.not.be.ok
})

it('an error should be thrown if the same static route is added twice', function () {
let instance = new Tree()

Expand Down

0 comments on commit 990c24d

Please sign in to comment.