@
zhicheng 首先应该参照 @
aleung 说的 rfc3986, 我贴的 rfc1738 已经过时了。在 rfc3986 中这两种方式都是规范的。
然后, 如果 hpath 是可以为空的, 那 BNF 应该是
hpath = *[ "/" hsegment ]
而不是
hpath = hsegment *[ "/" hsegment ]
这种方式代表至少有一个 hsegment. 后面的*代表 0 个或者多个[ "/" hsegment ]
可以参照 rfc822 以及 rfc1738 中的说明:
5. BNF for specific URL schemes
This is a BNF-like description of the Uniform Resource Locator
syntax, using the conventions of RFC822, except that "|" is used to
designate alternatives, and brackets [] are used around optional or
repeated elements. Briefly, literals are quoted with "", optional
elements are enclosed in [brackets], and elements may be preceded
with <n>* to designate n or more repetitions of the following
element; n defaults to 0.