| 1 | export const NAME = "node-url-import"; |
| 2 | export const MAX_REDIRECTS = 10; |
| 3 | export const DEFAULT_CDN = "https://esm.sh/"; |
| 4 | export const FETCH_TIMEOUT_MS = 60_000; |
| 5 | const MAX_TIMEOUT_MS = 2_147_483_647; |
| 6 | |
| 7 | export function getFetchTimeoutMs(timeoutMs = FETCH_TIMEOUT_MS): number { |
| 8 | if (!Number.isInteger(timeoutMs) || timeoutMs <= 0 || timeoutMs > MAX_TIMEOUT_MS) { |
| 9 | throw new RangeError(`The fetch timeout must be a positive integer no greater than ${MAX_TIMEOUT_MS}`); |
| 10 | } |
| 11 | return timeoutMs; |
| 12 | } |
| 13 | |
| 14 | export function isHttpUrl(value: string): boolean { |
| 15 | return /^https?:\/\//i.test(value); |
| 16 | } |
| 17 | |