小智 46
主机名中不允许使用下划线.因此,some_place.com不是有效的URL,因为主机名无效.URL中允许使用下划线.因此some-place.com/which_place/是完全合法的,除了其他问题.
来自RFC 1738:
主办
Run Code Online (Sandbox Code Playgroud)[...] Fully qualified domain names take the form as described in Section 3.5 of RFC 1034 [13] and Section 2.1 of RFC 1123 [5]: a sequence of domain labels separated by ".", each domain label starting and ending with an alphanumerical character and possibly also containing "-" characters. The rightmost domain label will never start with a digit, though, which syntactically distinguishes all domain names from the IP addresses.
Uni*_*key 33
当您阅读a_long_sentence_with_many_underscores时,因为您正在通过字母或单词识别来阅读它,您的眼睛会沿着线条的中间跟踪,但是当您到达下划线时,您的眼睛更有可能向下追踪并备份下一个单词.
当你阅读长篇大论时,你的眼睛会沿着同一个地平线追踪,通过视觉,你的大脑更容易尝试忽略它们.
另一个很好的理由是,当单词分隔符为破折号时,Google和其他搜索引擎会将与搜索字词匹配的网址排名更高.
顺便说一句......使用下划线时,似乎有几个 Java 网络库将无法正确解释 URL:
URI uri = URI.create("http://www.google-plus.com/");
System.out.println(uri.getHost()); // prints www.google-plus.com
URI uri = URI.create("http://www.google_plus.com/");
System.out.println(uri.getHost()); // prints null
Run Code Online (Sandbox Code Playgroud)