diff --git a/init.rb b/init.rb index 6ad5881..238b5de 100644 --- a/init.rb +++ b/init.rb @@ -10,7 +10,7 @@ module ValidatesUrlFormatOf \A https?:// # http:// or https:// ([^\s:@]+:[^\s:@]*@)? # optional username:pw@ - ( ((#{ALNUM}+\.)*xn---*)?#{ALNUM}+([-.]#{ALNUM}+)*\.[a-z]{2,6}\.? | # domain (including Punycode/IDN)... + ( ((#{ALNUM}+\.)*xn---*)?#{ALNUM}+([-.]#{ALNUM}+)*\.[a-z]{2,6}\.?(--#{ALNUM}*)? | # domain (including Punycode/IDN)... #{IPv4_PART}(\.#{IPv4_PART}){3} ) # or IPv4 (:\d{1,5})? # optional port ([/?]\S*)? # optional /whatever or ?whatever diff --git a/test/validates_url_format_of_test.rb b/test/validates_url_format_of_test.rb index 05e31cb..bcb728e 100644 --- a/test/validates_url_format_of_test.rb +++ b/test/validates_url_format_of_test.rb @@ -70,6 +70,7 @@ def test_should_allow_valid_urls 'http://www.xn--rksmrgs-5wao1o.nu', 'http://foo.bar.xn--rksmrgs-5wao1o.nu', 'https://www.xn----ylbbafnbqebomc7ds.com.gr', + 'http://xn--80agkgigub5kqa.xn--p1ai', 'http://example.com.', # Explicit TLD root period 'http://example.com./foo' ].each do |url|