URL.parse() vs new URL() Playground

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…

Why it matters

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.

The key idea

Readable is not the same as safe

Common mistakes

Try it in this playground