← You've been wrapping `new URL()` in try/catch. `URL.parse()` does it natively.Quiz

URL.canParse() and URL.parse() — safe URL parsing

Parsing an untrusted URL used to mean wrapping new URL() in try/catch. URL.canParse() and URL.parse() are the native alternatives. These questions check what each method returns on valid and invalid input, when to reach for each one, the double-parse antipattern, and the browser support timeline.

questions7
pass mark70%
feedbackinstant

No account needed. Every answer is explained as you go, with a reference to the spec or MDN — pass and you can claim a certificate.