{
  "version": 3,
  "sources": ["../../../src/components/link-control/normalize-url.js"],
  "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { getProtocol, prependHTTPS } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { isHashLink, isRelativePath } from './is-url-like';\nimport { TEL_TYPE, MAILTO_TYPE, INTERNAL_TYPE, URL_TYPE } from './constants';\n\n/**\n * Normalizes a URL string by adding https:// protocol if needed.\n * This function determines the final URL that will be saved.\n *\n * Normalization rules:\n * - Bare domains (wordpress.org, www.wordpress.org) \u2192 prepend https://\n * - URLs with explicit protocols (http://, https://, mailto:, tel:, etc.) \u2192 keep as-is\n * - Relative paths (/, ./, ../) \u2192 keep as-is\n * - Hash links (#section) \u2192 keep as-is\n *\n * @param {string} url - The URL to normalize\n * @return {Object} An object containing the normalized URL and its type\n */\nexport default function normalizeUrl( url ) {\n\tconst trimmedUrl = url?.trim();\n\n\tif ( ! trimmedUrl ) {\n\t\treturn { url: trimmedUrl, type: URL_TYPE };\n\t}\n\n\tlet type = URL_TYPE;\n\tconst protocol = getProtocol( trimmedUrl ) || '';\n\n\t// Determine the type based on the URL format\n\tif ( protocol.includes( 'mailto' ) ) {\n\t\ttype = MAILTO_TYPE;\n\t} else if ( protocol.includes( 'tel' ) ) {\n\t\ttype = TEL_TYPE;\n\t} else if ( trimmedUrl?.startsWith( '#' ) ) {\n\t\ttype = INTERNAL_TYPE;\n\t}\n\n\t// Hash links, relative paths, query parameters, and URLs with protocols should not be modified\n\tif (\n\t\tisHashLink( trimmedUrl ) ||\n\t\tisRelativePath( trimmedUrl ) ||\n\t\ttrimmedUrl.startsWith( '?' ) ||\n\t\tprotocol\n\t) {\n\t\treturn { url: trimmedUrl, type };\n\t}\n\n\t// Bare domains need https:// prepended\n\treturn { url: prependHTTPS( trimmedUrl ), type };\n}\n"],
  "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAA0C;AAK1C,yBAA2C;AAC3C,uBAA+D;AAehD,SAAR,aAA+B,KAAM;AAC3C,QAAM,aAAa,KAAK,KAAK;AAE7B,MAAK,CAAE,YAAa;AACnB,WAAO,EAAE,KAAK,YAAY,MAAM,0BAAS;AAAA,EAC1C;AAEA,MAAI,OAAO;AACX,QAAM,eAAW,wBAAa,UAAW,KAAK;AAG9C,MAAK,SAAS,SAAU,QAAS,GAAI;AACpC,WAAO;AAAA,EACR,WAAY,SAAS,SAAU,KAAM,GAAI;AACxC,WAAO;AAAA,EACR,WAAY,YAAY,WAAY,GAAI,GAAI;AAC3C,WAAO;AAAA,EACR;AAGA,UACC,+BAAY,UAAW,SACvB,mCAAgB,UAAW,KAC3B,WAAW,WAAY,GAAI,KAC3B,UACC;AACD,WAAO,EAAE,KAAK,YAAY,KAAK;AAAA,EAChC;AAGA,SAAO,EAAE,SAAK,yBAAc,UAAW,GAAG,KAAK;AAChD;",
  "names": []
}
