MCPcopy
hub / github.com/simstudioai/sim / parseUrl

Function parseUrl

packages/utils/src/media-embed.ts:21–28  ·  view source on GitHub ↗

Parse a URL, tolerating scheme-less inputs (https is assumed). Returns null if unparseable.

(url: string)

Source from the content-addressed store, hash-verified

19
20/** Parse a URL, tolerating scheme-less inputs (https is assumed). Returns null if unparseable. */
21function parseUrl(url: string): URL | null {
22 for (const candidate of [url, `https://${url}`]) {
23 try {
24 return new URL(candidate)
25 } catch {}
26 }
27 return null
28}
29
30/**
31 * Whether `host` is one of `domains` or a subdomain of one (e.g. `m.youtube.com`

Callers 1

getEmbedInfoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected