(url, domains)
| 257 | } |
| 258 | |
| 259 | function shouldProcessUrl(url, domains) { |
| 260 | let parsed; |
| 261 | try { |
| 262 | parsed = new URL(url); |
| 263 | } catch { |
| 264 | return false; |
| 265 | } |
| 266 | |
| 267 | if (!domains.some((domain) => hostMatches(parsed.hostname, domain))) { |
| 268 | return false; |
| 269 | } |
| 270 | |
| 271 | return IMAGE_EXTENSIONS.has(path.extname(parsed.pathname).toLowerCase()); |
| 272 | } |
| 273 | |
| 274 | function hostMatches(hostname, domain) { |
| 275 | return hostname === domain || hostname.endsWith(`.${domain}`); |
no test coverage detected