URI if form “scheme:/path”是否有效?
Is URI if form “scheme:/path” valid?
我使用此代码在 Java 中创建了 URI:
new URI(/*scheme*/ "scheme", /*host*/ null, /*path*/ "/42", /*fragment*/ null);
当我将此 URI 转换为字符串时,我得到 scheme:/42
。 scheme:/path
格式的 URI 是否有效?
当我使用 new URI("scheme", "", "/path", null)
时,我得到 scheme:///path
。我知道这是有效的(比如 file:///
URI)。这些 URI 是否有不同的含义?
参见Wikipedia article on URI and diagram on Wikimedia Commons:
URI = scheme:[//authority]path[?query][#fragment]
[…]
//authority
(用户+密码+主机+端口)部分可以跳过。 path
组件 在 //authority
部分之后包含 /
。
此 URI 有效。
我使用此代码在 Java 中创建了 URI:
new URI(/*scheme*/ "scheme", /*host*/ null, /*path*/ "/42", /*fragment*/ null);
当我将此 URI 转换为字符串时,我得到 scheme:/42
。 scheme:/path
格式的 URI 是否有效?
当我使用 new URI("scheme", "", "/path", null)
时,我得到 scheme:///path
。我知道这是有效的(比如 file:///
URI)。这些 URI 是否有不同的含义?
参见Wikipedia article on URI and diagram on Wikimedia Commons:
URI = scheme:[//authority]path[?query][#fragment]
[…]
//authority
(用户+密码+主机+端口)部分可以跳过。 path
组件 在 //authority
部分之后包含 /
。
此 URI 有效。