MCPcopy
hub / github.com/darkreader/darkreader / matchPath

Function matchPath

src/utils/url.ts:568–595  ·  view source on GitHub ↗
(node: URLTrieNode, index: number)

Source from the content-addressed store, hash-verified

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

Callers 1

matchHostFunction · 0.85

Calls 2

pushFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected