是否允许自定义 URI 方案对其内容使用 hash/pound 符号 (#)?

Is a custom URI scheme allowed to use the hash/pound sign (#) for it's content?

在 Kullo,我们使用格式为 username#domain.tld(例如 hi#kullo.net)的地址,其中 # 是一个常量,类似于电子邮件地址中的 @

现在设计用于向给定地址发送消息的正确 URI 格式是什么:

kullo:username#domain.tldkullo:username%23domain.tld?

首选第一个,因为它简单。但是考虑到 URI 的规则,我是否可以为我的自定义方案 kullo 制作 # 而不是片段分隔符?

根据 RFC 3986,井号是保留的,但这并不意味着自定义 URI 方案必须使用它作为分隔符:

2.2. Reserved Characters

URIs include components and subcomponents that are delimited by characters in the "reserved" set. These characters are called "reserved" because they may (or may not) be defined as delimiters by the generic syntax, by each scheme-specific syntax, or by the implementation-specific syntax of a URI's dereferencing algorithm. If data for a URI component would conflict with a reserved character's purpose as a delimiter, then the conflicting data must be percent-encoded before the URI is formed.

[...]

Thus, characters in the reserved set are protected from normalization and are therefore safe to be used by scheme-specific and producer-specific algorithms for delimiting data subcomponents within a URI.

[...]

URI producing applications should percent-encode data octets that correspond to characters in the reserved set unless these characters are specifically allowed by the URI scheme to represent data in that component. If a reserved character is found in a URI component and no delimiting role is known for that character, then it must be interpreted as representing the data octet corresponding to that character's encoding in US-ASCII.

所以你可以决定不转义它,但是你会失去规范化功能:

kullo:username#domain.tld != kullo:username%23domain.tld

但是

kullo:username#domain.tld == kullo:%75sername#domain.tld