最近我看到这样的工作代码块:
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>根据RFC 2396(URI Syntax)和RFC 2616(HTTP 1.1),这两个开头的URI都是有效的,但不幸的是,RFC并没有真正解释它们。
任何人都可以指出一个资源,解释浏览器会/应该/如何处理这些URI?
Lately I saw working code-blocks like this:
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>And according to RFC 2396 (URI Syntax) and RFC 2616 (HTTP 1.1) these URI starting with two slashes are valid, but unfortunately the RFCs don't really explain them.
Can anyone point me to a resource which explains how browsers will/should/do process these URIs?
最满意答案
您要查找的资源是RFC 3986 。
见第4.2节和第5.4节。 从后者引用:
http://a/b/c/d;p?q参考分辨率示例
在具有明确定义的基本URI的表示中:
相对引用将转换为其目标URI,如下所示:
"g:h" = "g:h" "g" = "http://a/b/c/g" "./g" = "http://a/b/c/g" "g/" = "http://a/b/c/g/" "/g" = "http://a/g" "//g" = "http://g" "?y" = "http://a/b/c/d;p?y" "g?y" = "http://a/b/c/g?y" "#s" = "http://a/b/c/d;p?q#s" "g#s" = "http://a/b/c/g#s" "g?y#s" = "http://a/b/c/g?y#s" ";x" = "http://a/b/c/;x" "g;x" = "http://a/b/c/g;x" "g;x?y#s" = "http://a/b/c/g;x?y#s" "" = "http://a/b/c/d;p?q" "." = "http://a/b/c/" "./" = "http://a/b/c/" ".." = "http://a/b/" "../" = "http://a/b/" "../g" = "http://a/b/g" "../.." = "http://a/" "../../" = "http://a/" "../../g" = "http://a/g"
这意味着当基本URI为http://a/b/c/d;p?q并且您使用//g ,相对引用将转换为http://g 。
The resource you're looking for is the RFC 3986.
See Section 4.2 and Section 5.4. Quoting from the latter:
http://a/b/c/d;p?qReference Resolution Examples
Within a representation with a well defined base URI of:
a relative reference is transformed to its target URI as follows:
"g:h" = "g:h" "g" = "http://a/b/c/g" "./g" = "http://a/b/c/g" "g/" = "http://a/b/c/g/" "/g" = "http://a/g" "//g" = "http://g" "?y" = "http://a/b/c/d;p?y" "g?y" = "http://a/b/c/g?y" "#s" = "http://a/b/c/d;p?q#s" "g#s" = "http://a/b/c/g#s" "g?y#s" = "http://a/b/c/g?y#s" ";x" = "http://a/b/c/;x" "g;x" = "http://a/b/c/g;x" "g;x?y#s" = "http://a/b/c/g;x?y#s" "" = "http://a/b/c/d;p?q" "." = "http://a/b/c/" "./" = "http://a/b/c/" ".." = "http://a/b/" "../" = "http://a/b/" "../g" = "http://a/b/g" "../.." = "http://a/" "../../" = "http://a/" "../../g" = "http://a/g"
This means that when the base URI is http://a/b/c/d;p?q and you use //g, the relative reference is transformed to http://g.
更多推荐
发布评论