Download ARTEX-main/web/src/lib/http-href.ts from ghostai1/WardenPEN: direct link, hf CLI and curl.
- Browser
- Download file 496 Bytes
-
https://huggingface.co/ghostai1/WardenPEN/resolve/main/ARTEX-main/web/src/lib/http-href.ts
- Command line
-
hf download hf://ghostai1/WardenPEN/ARTEX-main/web/src/lib/http-href.ts
-
curl -L -o http-href.ts https://huggingface.co/ghostai1/WardenPEN/resolve/main/ARTEX-main/web/src/lib/http-href.ts
496 Bytes
| // httpHref returns raw when it is an http(s) URL, otherwise undefined. | |
| // Asset URLs are operator/target-supplied; javascript: and data: must not | |
| // become href values. | |
| export function httpHref(raw: string | undefined | null): string | undefined { | |
| const s = (raw ?? "").trim(); | |
| if (!s) { | |
| return undefined; | |
| } | |
| try { | |
| const u = new URL(s); | |
| if (u.protocol === "http:" || u.protocol === "https:") { | |
| return u.href; | |
| } | |
| } catch { | |
| // not a URL | |
| } | |
| return undefined; | |
| } | |