【发布时间】:2014-01-01 10:13:14
【问题描述】:
我对 URL 路径格式有疑问。
一个 url 有一个权限和一个路径。现在这里的问题是什么是空路径(没有路径段)。
考虑以下。
- 前导斜杠是路径的一部分。 '/' 是 http.//domain/ 中的路径
- 空路径实际上是一个段,其名称为“”。
这两个假设会导致以下结果:
A. http.//domain?query、http.//domain#fraction、http.//domain 将是合法的 URL 字符串
B.将为给定域提取以下域路径。
- http.//域 -> 段 = {}
- http.//domain/ -> 段 = {''}
- http.//domain/a -> 段 = {'a'}
- http.//domain/a/ -> 段 = {'a', ''}
- http.//domain/a/b -> 段 = {'a', 'b'}
- http.//domain/a/b/ -> 段 = {'a', 'b', ''}
- http.//domain//// -> 段 = {'', '', '', '', ''}`
这是正确的解释吗?
PS:我使用“http.//”而不是“http://”以避免抱怨非法链接。
【问题讨论】:
-
我相信最后一个例子应该是
http.//domain//// -> segments = {'', '', '', ''},四个斜线表示四个段,而不是五个。