UNPKG

@mswjs/interceptors

Version:

Low-level HTTP/HTTPS/XHR/fetch request interception library.

14 lines (13 loc) 299 B
/** * Returns a boolean indicating whether the given URL string * can be parsed into a `URL` instance. * A substitute for `URL.canParse()` for Node.js 18. */ export function canParseUrl(url: string): boolean { try { new URL(url) return true } catch (_error) { return false } }