MCPcopy
hub / github.com/darkreader/darkreader / matchHost

Function matchHost

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

Source from the content-addressed store, hash-verified

525 }
526
527 const matchHost = (node: URLTrieNode, index: number) => {
528 const finalHostNode = node.hostNodes.get('');
529 const noMoreHostParts = index === u.hostParts.length;
530 const value = noMoreHostParts ? '' : u.hostParts[index];
531
532 if (
533 finalHostNode && (
534 noMoreHostParts ||
535 node.key === '*' ||
536 (index === u.hostParts.length - 1 && value === 'www')
537 )
538 ) {
539 if (finalHostNode.data) {
540 push(finalHostNode.data);
541 if (breakOnFirstMatch) {
542 return;
543 }
544 }
545 matchPath(finalHostNode, 0);
546 }
547
548 if (noMoreHostParts) {
549 return;
550 }
551
552 const nodes = node.hostNodes;
553 const wildcardNode = nodes.get('*');
554 if (wildcardNode) {
555 matchHost(wildcardNode, index + 1);
556 }
557
558 if (breakOnFirstMatch && matches.length > 0) {
559 return;
560 }
561
562 const keyNode = nodes.get(value);
563 if (keyNode) {
564 matchHost(keyNode, index + 1);
565 }
566 };
567
568 const matchPath = (node: URLTrieNode, index: number) => {
569 const finalPathNode = node.pathNodes.get('');

Callers 1

Calls 3

matchPathFunction · 0.85
pushFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected