Sha256: 87a9021350f244b411531da65e5dedec7cab557fed05cf38c26c77cd9c185882

Contents?: true

Size: 502 Bytes

Versions: 1

Compression:

Stored size: 502 Bytes

Contents

module Superhosting
  module Patches
    module String
      module Punycode
        def punycode
          parts = self.split('.').map do |label|
            encoded = ::Punycode.encode(Unicode::normalize_KC(Unicode::downcase(label)))
            if encoded =~ /-$/
              encoded.chop!
            else
              'xn--' + encoded
            end
          end
          parts.join('.')
        end
      end
    end
  end
end

String.send(:include, Superhosting::Patches::String::Punycode)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
superhosting-0.0.2 lib/superhosting/patches/string/punycode.rb