Download packages/ui/src/components/editor/utils.ts from AUXteam/Midday: direct link, hf CLI and curl.
- Browser
- Download file 457 Bytes
-
https://huggingface.co/spaces/AUXteam/Midday/resolve/main/packages/ui/src/components/editor/utils.ts
- Command line
-
hf download hf://spaces/AUXteam/Midday/packages/ui/src/components/editor/utils.ts
-
curl -L -o utils.ts https://huggingface.co/spaces/AUXteam/Midday/resolve/main/packages/ui/src/components/editor/utils.ts
457 Bytes
| export function isValidUrlFormat(urlString: string) { | |
| try { | |
| new URL(urlString); | |
| return true; | |
| } catch (_error) { | |
| return false; | |
| } | |
| } | |
| export function formatUrlWithProtocol(rawUrlString: string) { | |
| if (isValidUrlFormat(rawUrlString)) return rawUrlString; | |
| try { | |
| if (rawUrlString.includes(".") && !rawUrlString.includes(" ")) { | |
| return new URL(`https://${rawUrlString}`).toString(); | |
| } | |
| } catch (_error) { | |
| return null; | |
| } | |
| } | |