救命!我发现某种 url 编码方式会破坏链接。对于记录%2f
表示正斜杠字符:/
现在,考虑一下:原始链接:http://dottech.org/95285/this-is-the-pacific-barreleye-a-fish-with-a-transparent-head-amazing-photo-of-the-day
javascript ( encodeURIComponent
) urlencoded 链接:http://dottech.org%2f95285%2fthis-is-the-pacific-barreleye-a-fish-with-a-transparent-head-amazing-photo-of-the-day
现在,如果您将编码的链接粘贴到浏览器的地址栏中,它就会损坏(Firefox、Chrome、IE)。
但是,如果您不对第一个正斜杠进行 url 编码,它可以完美地工作:'http://dottech.org/95285%2fthis-is-the-pacific-barreleye-a-fish-with-a-transparent-head-amazing-photo-of-the-day
为什么?