(host: string, wildcards: string[])
| 68 | * of domain wildcards. |
| 69 | */ |
| 70 | export function hostMatchesWildcards(host: string, wildcards: string[]): boolean { |
| 71 | for (const wildcard of wildcards) { |
| 72 | // Exact match always wins |
| 73 | if (host === wildcard) { |
| 74 | return true; |
| 75 | } |
| 76 | |
| 77 | // Wildcard match with leading *. |
| 78 | if (wildcard.startsWith('*.')) { |
| 79 | const suffix = wildcard.substring(2); |
| 80 | // Exact match or strict subdomain match |
| 81 | if (host === suffix || host.endsWith(`.${suffix}`)) { |
| 82 | return true; |
| 83 | } |
| 84 | } |
| 85 | // Wildcard match with leading */ |
| 86 | if (wildcard.startsWith('*/')) { |
| 87 | const suffix = wildcard.substring(2); |
| 88 | // Exact match or strict subpath match |
| 89 | if (host === suffix || host.endsWith(`/${suffix}`)) { |
| 90 | return true; |
| 91 | } |
| 92 | } |
| 93 | } |
| 94 | return false; |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * Ensure Hint field is in a shape we expect: |
no outgoing calls
no test coverage detected