URI 中方案后面的双斜杠的语义是什么?
根据 https://www.rfc-editor.org/rfc/rfc3986 和http://en.wikipedia.org/wiki/Uniform_resource_identifier,URI 在方案标识符后面可以包含也可以不包含双斜杠。这使得“urn:issn:1535-3613”成为有效的 URI,就像“http://stackoverflow.com”一样。
是否严格/正式需要包含双斜杠,或者它是可选的,无论如何,原因/语义是什么?回答时,请提供一个结论性的答案 - 不要只报告您的浏览器/库/...如何处理它。
According to https://www.rfc-editor.org/rfc/rfc3986 and http://en.wikipedia.org/wiki/Uniform_resource_identifier, a URI may or may not contain a double slash following the scheme identifier. This makes "urn:issn:1535-3613" a valid URI just as "http://stackoverflow.com".
Is there a strict/formal need to include the double slash or is it optional and in any case, what is the reason/semantics? When answering, please provide a conclusive answer - Don't just report how you browser/library/... handles it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它位于您链接的 RFC 中:如果有
//
,则意味着后面的内容是权限。请参阅第 3 节。因此,如果方案使用权限,它将在冒号后使用//
(如果该方案中需要权限,则需要它,或者如果授权在该方案中是可选的,则它是可选的)。mailto
不使用 URI 意义上的权限,因此mailto
URI 不包含//
。It's in the RFC you linked: If there is a
//
, it means that what follows that is the authority. See Section 3. So if the scheme uses an authority, it will use the//
after the colon (either requiring it, if authority is required in that scheme, or having it be optional if authority is optional in that scheme).mailto
doesn't use an authority in the URI sense, somailto
URIs don't include a//
.除了彻底解释答案的 RFC 之外,我想您可能会喜欢直接来自世界发明家的这句话万维网本人。
来源:http://www.wired.co.uk/news/archive/2014-02/06/tim-berners-lee-reclaim-the-web
Besides the RFC which thoroughly explains the answer, I thought you might like this quote straight from the inventor of the World Wide Web himself.
Source: http://www.wired.co.uk/news/archive/2014-02/06/tim-berners-lee-reclaim-the-web
好吧,如果你想要一个“结论性的答案”,我认为没有什么比官方的 HTTP 更结论性的了RFC文档(参见第3.2.2节,其中讨论了HTTP URL方案)。
Well, if you want a "conclusive answer", I think nothing is more conclusive than the official HTTP RFC document (see point 3.2.2 which talks about the HTTP URL scheme).