URI以两个斜杠开头...他们的行为如何?(URI starting with two slashes … how do they behave?)

编程入门 行业动态 更新时间:2024-10-21 23:24:15
URI以两个斜杠开头...他们的行为如何?(URI starting with two slashes … how do they behave?)

最近我看到这样的工作代码块:

<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节。 从后者引用:

参考分辨率示例

在具有明确定义的基本URI的表示中:

http://a/b/c/d;p?q

相对引用将转换为其目标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:

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"

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.

更多推荐

本文发布于:2023-07-05 07:00:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1034424.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:他们的   斜杠   开头   两个   URI

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!