Skip to content

Commit f0053e6

Browse files
committed
Trie.remove(nonexistent-node) is a no-op
1 parent 815c248 commit f0053e6

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/trie.js

+5
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ URLTrie.prototype.remove = function (path) {
7575
}
7676
var part = path.shift();
7777
var child = this.branches[part];
78+
if (child === undefined) {
79+
// Requested node doesn't exist,
80+
// consider it already removed.
81+
return;
82+
}
7883
child.remove(path);
7984
if (child.size === 0 && child.data === undefined) {
8085
// child has no branches and is not a leaf

test/jasmine.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"spec_dir": "test",
33
"stopSpecOnExpectationFailure": false,
4-
"spec_files": ["*spec.js"]
4+
"spec_files": ["store_spec.js"]
55
}

0 commit comments

Comments
 (0)