From f3b338e4b862ee6eadad0729a5aeb7fed89210dc Mon Sep 17 00:00:00 2001 From: bv-sumit Date: Wed, 9 Dec 2020 22:17:06 +0530 Subject: [PATCH 1/3] Fix #11 punnycode url with trailing -- and alnum fixed --- init.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From e151da0d0aae5faf492e94ed13c21a58441a0269 Mon Sep 17 00:00:00 2001 From: bv-sumit Date: Wed, 9 Dec 2020 22:25:10 +0530 Subject: [PATCH 2/3] Fix #11 added testcase --- test/validates_url_format_of_test.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/validates_url_format_of_test.rb b/test/validates_url_format_of_test.rb index 05e31cb..5d8a0f1 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| From 0b0b97344e23c3d47886d4d4a7cded48bb82cb2f Mon Sep 17 00:00:00 2001 From: bv-sumit Date: Wed, 9 Dec 2020 22:26:59 +0530 Subject: [PATCH 3/3] Fix #11 fixed indentation --- test/validates_url_format_of_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/validates_url_format_of_test.rb b/test/validates_url_format_of_test.rb index 5d8a0f1..bcb728e 100644 --- a/test/validates_url_format_of_test.rb +++ b/test/validates_url_format_of_test.rb @@ -70,7 +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://xn--80agkgigub5kqa.xn--p1ai', 'http://example.com.', # Explicit TLD root period 'http://example.com./foo' ].each do |url|