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

查看:169
本文介绍了URI以两个斜杠开头......他们的行为如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 < script type =

text / javascriptsrc =// ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js\"> ;</script>根据RFC 2396(URI语法)和RFC 2616(HTTP 1.1),这些以2开头的URI斜杠是有效的,但不幸的是,RFC并没有真正解释它们。

任何人都可以指定一个资源来解释浏览器将如何处理这些URI?

解决方案

您正在寻找的资源是 RFC 3986

请参阅第4.2节和第5.4节。引用后者:
$ b


参考解析示例



在具有明确定义的基本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


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?

解决方案

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.

这篇关于URI以两个斜杠开头......他们的行为如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆