← You've been wrapping `new URL()` in try/catch. `URL.parse()` does it natively.
Playground
URL.parse() vs new URL() — safe URL parsing
preview
Edits run in a sandbox in your browser — nothing is saved and nothing leaves the page.
Edits run in a sandbox in your browser — nothing is saved and nothing leaves the page.