Spaces:
Paused
Paused
File size: 299 Bytes
9ada4bc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
/**
* 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
}
}
|