当没有 www 时,ruby toUnicode fun 不会返回 IDN 站点。在网址中
在我的 Rails 应用程序中,我将 idn url 转换为 punycode,然后再转换回 idn。
但是如果我有这样的网址 http://日本语.jp(不带 www。)
domain = "http://日本語.jp"
punycode = Idna.toAscii(domain) => http://xn--blagzdfd.com
但尝试将其转换回 IDN 会失败,
idn = Idna.toUnicode(punycode) => xn--blagzdfd.com instead of http://日本語.jp
如果我们只添加 www,则 toUnicode 无法正确转换回来。到上面的 idn url,例如 http://www.日本语.jp< /a>
我错过了什么吗?
In my rails app, i convert a idn url to punycode and back to idn.
But if i have a url like this http://日本語.jp (without www.)
domain = "http://日本語.jp"
punycode = Idna.toAscii(domain) => http://xn--blagzdfd.com
but trying to convert it backto IDN fails
idn = Idna.toUnicode(punycode) => xn--blagzdfd.com instead of http://日本語.jp
the toUnicode converts back properly if we just add www. to the above idn url like http://www.日本語.jp
am i missing something??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
终于想通了。问题是 url 中的 http 部分。 toUnicode 的乐趣工作得很好。如果我们删除 url 中的 http 部分并传递它。
finally figured it out. the problem was the http part in the url. the toUnicode fun works fine. if we remove the http part in the url and pass it.