Normalize URL for deduplication — unwrap Next.js image proxy, strip w/q params
(u: string)
| 188 | |
| 189 | /** Normalize URL for deduplication — unwrap Next.js image proxy, strip w/q params */ |
| 190 | function normalizeUrl(u: string): string { |
| 191 | try { |
| 192 | const parsed = new URL(u); |
| 193 | if (parsed.pathname.includes("_next/image") && parsed.searchParams.has("url")) { |
| 194 | return decodeURIComponent(parsed.searchParams.get("url")!); |
| 195 | } |
| 196 | parsed.searchParams.delete("w"); |
| 197 | parsed.searchParams.delete("q"); |
| 198 | parsed.searchParams.delete("dpr"); |
| 199 | return parsed.toString(); |
| 200 | } catch { |
| 201 | return u; |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | /** |
| 206 | * Download fonts referenced in CSS and rewrite URLs to local paths. |
no test coverage detected