From bf94a2cd1cd4fb17a19074a9c01f5ab14b025274 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Tue, 2 Feb 2016 14:35:33 -0500 Subject: [PATCH] Support leftShort in Route.matchTrie --- js/src/route.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/js/src/route.js b/js/src/route.js index cdbb76e..4f943e6 100644 --- a/js/src/route.js +++ b/js/src/route.js @@ -543,8 +543,11 @@ function matchValue(r, v) { return failureResult; } -function matchTrie(o1, o2, seed) { +function matchTrie(o1, o2, seed, leftShortOpt) { var acc = typeof seed === 'undefined' ? Immutable.Set() : seed; // variable updated imperatively + var leftShort = leftShortOpt || function (v, r, acc) { + die("Route.matchTrie: left side short!"); + }; walk(o1, o2); return acc; @@ -563,9 +566,15 @@ function matchTrie(o1, o2, seed) { r2 = expandWildseq(r2.trie); } - if (r1 instanceof $Success && r2 instanceof $Success) { - acc = matchTrieSuccesses(r1.value, r2.value, acc); + if (r1 instanceof $Success) { + if (r2 instanceof $Success) { + acc = matchTrieSuccesses(r1.value, r2.value, acc); + } else { + acc = leftShort(r1.value, r2, acc); + } return; + } else if (r2 instanceof $Success) { + die("Route.matchTrie: right side short!"); } var w1 = rlookup(r1, __);