准备搭建GitHub-pages发现一个有趣的问题:
通过jkeyll生成静态页面,本地测试时发现,由于_config.yml 中设置 baseUrl = /,生成的index.html只要包含链接,href即变成//开头。chrome似乎对于//开头的路径有特殊的解析规则(本地环境localhost):
<li><a href="/2016/01/10/first-posts.html">my first post</a></li>
在http://localhost/index.html中点击时,会自动跳转为
http://0.0.7.224/01/10/first-posts.html
直接打开first-posts页面,其中存在返回链接:
<a href="//index.html">Go back</a>
点击时跳转成
稍微测试了一下。"//1"代表"0.0.0.1"的保留地址,以此向上类推,似乎是chrome有意为之,但是safari却把"//"按"/"处理,所以浏览器点击链接时无异常。
chrome这种设定有什么说法么,似乎没有看到相关资料。
(有误,safari对所有的//都会忽略主机名,同上述的第二种情况.服务器上测试也是如此)
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
:///;?#
each of which, except , may be absent from a particular URL.
These components are defined as follows (a complete BNF is provided
in Section 2.2):
scheme ":" ::= scheme name, as per Section 2.1 of RFC 1738 [2].
"//" net_loc ::= network location and login information, as per
Section 3.1 of RFC 1738 [2].
"/" path ::= URL path, as per Section 3.1 of RFC 1738 [2].
";" params ::= object parameters (e.g., ";type=a" as in
Section 3.2.2 of RFC 1738 [2]).
"?" query ::= query information, as per Section 3.3 of
RFC 1738 [2].
"#" fragment ::= fragment identifier.
: 之前是 scheme
// 以后 / 之前是 net_loc 主机地址
比如当前页面有个链接 //segmentfault.com/q/1010000004282189
是 segmentfault.com 主机下面的 /q/1010000004282189
即 http://segmentfault.com/q/1010000004282189
而不是 http://segmentfault.com/segmentfault.com/q/1010000004282189
这种写法一般还用于同时解决http和https的问题,省略了'http:' 'https:' 浏览器根据当前协议处理 url
你在本地页面有这个链接 那么结果就是 file://segmentfault.com/q/1010000004282189
评论
全部评论 (0)