或许不一定要在匹配 URL 的时候带上中文字符?

2015-09-15 13:23:14 +08:00
 raincious
比如这贴:
https://www.v2ex.com/t/220720#r_2427082

逗号被匹配成了 URL 的一部分。

根据 RFC2396 http://www.ietf.org/rfc/rfc2396.txt (参考 http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html )中的 2.1 URI and non-ASCII characters :

In the simplest case, the original character sequence contains only
characters that are defined in US-ASCII, and the two levels of
mapping are simple and easily invertible: each 'original character'
is represented as the octet for the US-ASCII code for it, which is,
in turn, represented as either the US-ASCII character, or else the
"%" escape sequence for that octet.

当然下文还提到一个复杂情况的。但是鉴于浏览器会在复制非 ASCII 字符的时候自动进行% escape ,那么其实也就几乎可以忽略那个“复杂情况”了。
1922 次点击
所在节点    反馈
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/220824

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX