Download wp-calypso/client/site-profiler/utils/normalize-whois-url.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 602 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/site-profiler/utils/normalize-whois-url.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/site-profiler/utils/normalize-whois-url.ts
-
curl -L -o normalize-whois-url.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/site-profiler/utils/normalize-whois-url.ts
602 Bytes
| import { normalizeWhoisField } from './normalize-whois-entry'; | |
| // Normalize a WHOIS URL. | |
| export function normalizeWhoisURL( url: string | string[] | undefined ): string { | |
| let normalisedURL = normalizeWhoisField( url ); | |
| if ( normalisedURL === '' ) { | |
| return normalisedURL; | |
| } | |
| // Add a protocol if one is missing (assume HTTPS). | |
| if ( ! /^(http|https):\/\//.test( normalisedURL ) ) { | |
| normalisedURL = `https://${ normalisedURL }`; | |
| } | |
| try { | |
| // Throw an error if the URL is invalid. | |
| const urlObject = new URL( normalisedURL ); | |
| return urlObject.href; | |
| } catch ( error ) { | |
| return ''; | |
| } | |
| } | |