{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../../src/core/web-research/url.ts"],"names":[],"mappings":"AAEA,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAY/D;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAgBxD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMrD","sourcesContent":["const TRACKING_PARAMETERS = new Set([\"fbclid\", \"gclid\", \"mc_cid\", \"mc_eid\"]);\n\nexport function sanitizeUrlForDiagnostics(value: string): string {\n\ttry {\n\t\tconst url = new URL(value);\n\t\turl.username = \"\";\n\t\turl.password = \"\";\n\t\tfor (const key of [...url.searchParams.keys()]) {\n\t\t\tif (/token|key|secret|auth|password|signature/i.test(key)) url.searchParams.set(key, \"[REDACTED]\");\n\t\t}\n\t\treturn url.toString();\n\t} catch {\n\t\treturn \"[invalid URL]\";\n\t}\n}\n\nexport function canonicalizeWebUrl(value: string): string {\n\tconst url = new URL(value);\n\turl.hash = \"\";\n\turl.hostname = url.hostname.toLowerCase();\n\tif ((url.protocol === \"http:\" && url.port === \"80\") || (url.protocol === \"https:\" && url.port === \"443\")) {\n\t\turl.port = \"\";\n\t}\n\tconst entries = [...url.searchParams.entries()]\n\t\t.filter(([key]) => !key.toLowerCase().startsWith(\"utm_\") && !TRACKING_PARAMETERS.has(key.toLowerCase()))\n\t\t.sort(([leftKey, leftValue], [rightKey, rightValue]) =>\n\t\t\tleftKey === rightKey ? leftValue.localeCompare(rightValue) : leftKey.localeCompare(rightKey),\n\t\t);\n\turl.search = \"\";\n\tfor (const [key, valuePart] of entries) url.searchParams.append(key, valuePart);\n\tif (url.pathname !== \"/\") url.pathname = url.pathname.replace(/\\/$/, \"\");\n\treturn url.toString();\n}\n\nexport function normalizeDomain(value: string): string {\n\treturn value\n\t\t.trim()\n\t\t.toLowerCase()\n\t\t.replace(/^www\\./, \"\")\n\t\t.replace(/\\.$/, \"\");\n}\n"]}