The address check at the counter: what happens to the queue when new URL() rejects one slip, what URL.parse() gives, then check the protocol and the hostname…
Forms, a ?next= parameter after login, user-made links: all URLs you cannot trust. Reading them without a crash is step one; checking the parsed protocol and hostname is the step that makes it safe.
Readable is not the same as safe
new URL() on user input without try/catch One broken input = an uncaught exception: the flow stops (here: the queue jams). Use URL.parse() and check for null, or wrap it in try/catch./path alone is not valid without a base. Pass a second argument: URL.parse('/path', 'https://site.id').URL.canParse arrived before URL.parse, and both are still new. Check first (typeof URL.parse === 'function'), then fall back to try/catch with new URL.new URL() meet a broken slip Situation 1: one uncaught throw stops the forEach; Dina is never served.URL.parse() give null No exception: if (!url) is enough.URL.parse('/rak/7', BASE) becomes a full URL.javascript: by url.protocol canParse accepts it; only the protocol check refuses.