| 566 | }; |
| 567 | |
| 568 | const matchPath = (node: URLTrieNode, index: number) => { |
| 569 | const finalPathNode = node.pathNodes.get(''); |
| 570 | const noMorePathParts = index === u.pathParts.length; |
| 571 | const value = noMorePathParts ? '' : u.pathParts[index]; |
| 572 | |
| 573 | if (finalPathNode && finalPathNode.data) { |
| 574 | push(finalPathNode.data); |
| 575 | } |
| 576 | |
| 577 | if (noMorePathParts) { |
| 578 | return; |
| 579 | } |
| 580 | |
| 581 | const nodes = node.pathNodes; |
| 582 | const wildcardNode = nodes.get('*'); |
| 583 | if (wildcardNode) { |
| 584 | matchPath(wildcardNode, index + 1); |
| 585 | } |
| 586 | |
| 587 | if (breakOnFirstMatch && matches.length > 0) { |
| 588 | return; |
| 589 | } |
| 590 | |
| 591 | const keyNode = nodes.get(value); |
| 592 | if (keyNode) { |
| 593 | matchPath(keyNode, index + 1); |
| 594 | } |
| 595 | }; |
| 596 | |
| 597 | matchHost(trie, 0); |
| 598 | |