URI 中方案后面的双斜杠的语义是什么?

发布于 2024-12-27 11:31:12 字数 458 浏览 3 评论 0原文

根据 https://www.rfc-editor.org/rfc/rfc3986http://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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

心碎的声音 2025-01-03 11:31:12

它位于您链接的 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, so mailto URIs don't include a //.

烟酒忠诚 2025-01-03 11:31:12

除了彻底解释答案的 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.

When [Sir Tim Berners-Lee] was asked what he would have done
differently, the answer was easy. "I would have got rid of the slash
slash after the colon. You don't really need it. It just seemed like a
good idea at the time."

Source: http://www.wired.co.uk/news/archive/2014-02/06/tim-berners-lee-reclaim-the-web

再见回来 2025-01-03 11:31:12

好吧,如果你想要一个“结论性的答案”,我认为没有什么比官方的 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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文