(hostname: string, pathname: string)
| 152 | })() |
| 153 | |
| 154 | export function isPreapprovedHost(hostname: string, pathname: string): boolean { |
| 155 | if (HOSTNAME_ONLY.has(hostname)) return true |
| 156 | const prefixes = PATH_PREFIXES.get(hostname) |
| 157 | if (prefixes) { |
| 158 | for (const p of prefixes) { |
| 159 | // Enforce path segment boundaries: "/anthropics" must not match |
| 160 | // "/anthropics-evil/malware". Only exact match or a "/" after the |
| 161 | // prefix is allowed. |
| 162 | if (pathname === p || pathname.startsWith(p + '/')) return true |
| 163 | } |
| 164 | } |
| 165 | return false |
| 166 | } |
| 167 |
no test coverage detected