@wordpress/url
Version:
WordPress URL utilities.
8 lines (7 loc) • 1.04 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../src/prepend-https.ts"],
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport { prependHTTP } from './prepend-http';\n\n/**\n * Prepends \"https://\" to a url, if it looks like something that is meant to be a TLD.\n *\n * Note: this will not replace \"http://\" with \"https://\".\n *\n * @param url The URL to test.\n *\n * @example\n * ```js\n * const actualURL = prependHTTPS( 'wordpress.org' ); // https://wordpress.org\n * ```\n *\n * @return The updated URL.\n */\nexport function prependHTTPS( url: string ): string {\n\tif ( ! url ) {\n\t\treturn url;\n\t}\n\n\t// If url starts with http://, return it as is.\n\tif ( url.startsWith( 'http://' ) ) {\n\t\treturn url;\n\t}\n\n\turl = prependHTTP( url );\n\n\treturn url.replace( /^http:/, 'https:' );\n}\n"],
"mappings": ";AAGA,SAAS,mBAAmB;AAgBrB,SAAS,aAAc,KAAsB;AACnD,MAAK,CAAE,KAAM;AACZ,WAAO;AAAA,EACR;AAGA,MAAK,IAAI,WAAY,SAAU,GAAI;AAClC,WAAO;AAAA,EACR;AAEA,QAAM,YAAa,GAAI;AAEvB,SAAO,IAAI,QAAS,UAAU,QAAS;AACxC;",
"names": []
}