开发者

converting escaped urls with punycode to utf, refactoring

I want to store all my url in readble utf8

class User < ActiveRecord::Base
  require 'addressable/uri'
  require 'idn'
  include IDN
  def service_url=(url)
    url = Addressable::URI.parse Addressable::URI.unescape(url)
    url.host = Idna.toUnicode url.host
    super url.to_s
  end
end

any hints for refactor开发者_JAVA百科ing or for more universal gems?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜