作者热门文章
- objective-c - iOS 5 : Can you override UIAppearance customisations in specific classes?
- iphone - 如何将 CGFontRef 转换为 UIFont?
- ios - 以编程方式关闭标记的信息窗口 google maps iOS
- ios - Xcode 5 - 尝试验证存档时出现 "No application records were found"
最近我看到了像这样的工作代码块:
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
并且根据 RFC 2396(URI 语法)和 RFC 2616(HTTP 1.1),这些以两个斜杠开头的 URI 是有效的,但不幸的是 RFC 并没有真正解释它们。
任何人都可以向我指出解释浏览器将/应该/确实如何处理这些 URI 的资源吗?
最佳答案
您正在寻找的资源是 RFC 3986 .
参见第 4.2 节和第 5.4 节。引用后者:
Reference Resolution Examples
Within a representation with a well defined base URI of:
http://a/b/c/d;p?q
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"
这意味着当基础 URI 是 http://a/b/c/d;p?q
而你使用 //g
时,相对引用转换为 http://g
。
关于html - URI 以两个斜杠开头……它们的行为如何?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4071117/
我是一名优秀的程序员,十分优秀!