3 ms·
You need the slashes. Otherwise how do you differentiate between: site:port/file (example.com:8080/myfile.htm) and protocol:site/file (http:example.com/myfile.h
by AndrewDucker 17y ago
You need the slashes. Otherwise how do you differentiate between:
site:port/file (example.com:8080/myfile.htm)
and
protocol:site/file (http:example.com/myfile.htm)
?
You could guess, based on where the full stops are, what's a numeric, etc. But you wouldn't be sure. Having dots for one separator, slashes for another and a double slash for the third makes it entirely clear where the breaks are.
- varikin 17y agoI thought he was referring to the http:// http:// or ftp://. Without them it could be http:news.ycombinator.com or ftp:someserver.org. Edit: Ok I reread your comment and understand it better. That could be a problem but there could be other solutions, but at the moment, I don't care to think them through.
- warwick 17y agoIt really doesn't. For example, try the URL http://paulgraham.com://articles.html http://paulgraham.com://articles.html
- mseebach 17y agoYeah it does. try this: paulgraham.com://articles.html The separators aren't to be matched globally, their order in the URL matters. The first // separates protocol from host. The second // isn't really - it's one slash to separate path from host, and the second slash is part of the path.
- jpatte 17y agoI guess one could have chosen another separator than ":" as port number prefix so there would be no ambiguity with the protocol suffix :)
- axod 17y agoCheck if the part between the : and (end or /) is an integer? Sure, some browsers allow you to specify an IP address as an integer, but I don't think that's extremely useful.
- xtho 17y agosite:port/file could be considered illegal. A well-formed URL would be: protocol:site(:port)?(/path)? where (...)? denotes optional parts.
- gord 17y agoIve seen some heinous regexen floating around to recognize urls/uris. Be nice if this hadn't have happened - but he gave us the web, right, we can hardly complain.