lib/addressable/idna/native.rb in addressable-2.4.0 vs lib/addressable/idna/native.rb in addressable-2.5.0

- old
+ new

@@ -1,8 +1,8 @@ # encoding:utf-8 #-- -# Copyright (C) 2006-2015 Bob Aman +# Copyright (C) Bob Aman # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # @@ -32,21 +32,25 @@ IDN::Stringprep.nfkc_normalize(value.to_s) end def self.to_ascii(value) value.to_s.split('.', -1).map do |segment| - if segment.size > 0 + if segment.size > 0 && segment.size < 64 IDN::Idna.toASCII(segment) + elsif segment.size >= 64 + segment else '' end end.join('.') end def self.to_unicode(value) value.to_s.split('.', -1).map do |segment| - if segment.size > 0 + if segment.size > 0 && segment.size < 64 IDN::Idna.toUnicode(segment) + elsif segment.size >= 64 + segment else '' end end.join('.') end