MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / normalizeUrl

Function normalizeUrl

packages/cli/src/capture/assetDownloader.ts:190–203  ·  view source on GitHub ↗

Normalize URL for deduplication — unwrap Next.js image proxy, strip w/q params

(u: string)

Source from the content-addressed store, hash-verified

188
189/** Normalize URL for deduplication — unwrap Next.js image proxy, strip w/q params */
190function 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.

Callers 1

downloadAssetsFunction · 0.70

Calls 2

getMethod · 0.80
deleteMethod · 0.80

Tested by

no test coverage detected