Skip to main content

6. Normalization and Comparison (规范化和比较)

6.1. Equivalence (等价性)

URI等价性的定义取决于应用程序的需求。

6.2. Comparison Ladder (比较阶梯)

6.2.1. Simple String Comparison (简单字符串比较)

最快但最不准确的比较方法。

6.2.2. Syntax-Based Normalization (基于语法的规范化)

包括:

  • 大小写规范化(方案和主机)
  • 百分号编码规范化
  • 路径段规范化

示例:

HTTP://Example.COM/path  →  http://example.com/path
http://example.com/%7Euser → http://example.com/~user
http://example.com/a/./b/../c → http://example.com/a/c

6.2.3. Scheme-Based Normalization (基于方案的规范化)

移除默认端口等。

示例:

http://example.com:80/  →  http://example.com/
https://example.com:443/ → https://example.com/

6.2.4. Protocol-Based Normalization (基于协议的规范化)

需要访问资源的协议特定知识。