Stage 01
Validating the link before anything is fetched
The first thing that happens to a pasted URL is that it gets taken apart rather than trusted. The string is length-checked, parsed into a real URL object, and matched against the set of hosts the service knows how to handle. A URL that does not parse, or that points somewhere unexpected, is rejected at this boundary before a single outbound byte is sent.
Short links need an extra step. A youtu.be, pin.it or fb.watch address does not contain the identifier the extractor needs, so it has to be followed to its destination. Those redirects are followed deliberately rather than blindly: each hop is re-validated against the same host allow-list, which stops a short link from being used to point the server at an address it would never accept directly.
Only once the final URL is known and permitted does the extractor run. This ordering matters more than it sounds — a media service that fetches first and validates second is a server-side request forgery waiting to happen.