2 ms·
That'd be because type-1 fragments can be parsed by prefixing them with http:// http:// - or, more technically, humans treat the scheme as implicit and assume t
by groby_b 10y ago
That'd be because type-1 fragments can be parsed by prefixing them with http:// http:// - or, more technically, humans treat the scheme as implicit and assume the first component is always the net location. (a.k.a domain name)
Type-2 URLs are all considered relative URLs, which is why all URL libraries have a resolver concept for relative URLs. (RFC1808 has the gory details.)
The problem with type-1's is that they're not in the correct shape for relative address resolution, and so you're always engaging in a bit of gymnastics figuring out if somebody typed out part of the implicit agreement. And if you were to treat them as relative, there's ambiguity, so they can't be allowed in HTML pages.
I.e. href="www.example.com" is not clear in type-1 - it could be a domain, it could be a relative URL for the www.example.com file. In type-2, that's entirely clear - there's no scheme, and no net location, so it must be a path.
Conversely, we can't use type-2 urls exclusively, because humans would quickly realize that all useful urls start with a double-slash, and would want to start leaving that off, because "all URLs are like that". Most people oddly lack the ability to keep everything strictly clean according to a beautiful grammar and instead thing eliding common prefixes is fine, even if they span multiple distinct items. (There's a lesson for people who design grammars in there, but it's too late to learn the lesson on the web)
And here we are.
And don't even get me started on the fact that the address bar, on top of all of that, also needs to try to figure out if it's a URL (and which kind), or a query, or maybe a prefix for a custom search engine.
As usual, having users makes things really complicated ;)