Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow explicit root period ("http://example.com./foo").

  • Loading branch information...
commit b7af83c4ccea3fd910fd3e2b250bf5affff05f1b 1 parent 6ed0c34
@henrik henrik authored
Showing with 9 additions and 7 deletions.
  1. +6 −6 init.rb
  2. +3 −1 test/validates_url_format_of_test.rb
View
12 init.rb
@@ -2,12 +2,12 @@ module ValidatesUrlFormatOf
IPv4_PART = /\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]/ # 0-255
REGEXP = %r{
\A
- https?:// # http:// or https://
- ([^\s:@]+:[^\s:@]*@)? # optional username:pw@
- ( (xn--)?[^\W_]+([-.][^\W_]+)*\.[a-z]{2,6} | # domain (including Punycode/IDN)...
- #{IPv4_PART}(\.#{IPv4_PART}){3} ) # or IPv4
- (:\d{1,5})? # optional port
- ([/?]\S*)? # optional /whatever or ?whatever
+ https?:// # http:// or https://
+ ([^\s:@]+:[^\s:@]*@)? # optional username:pw@
+ ( (xn--)?[^\W_]+([-.][^\W_]+)*\.[a-z]{2,6}\.? | # domain (including Punycode/IDN)...
+ #{IPv4_PART}(\.#{IPv4_PART}){3} ) # or IPv4
+ (:\d{1,5})? # optional port
+ ([/?]\S*)? # optional /whatever or ?whatever
\Z
}iux
View
4 test/validates_url_format_of_test.rb
@@ -55,7 +55,9 @@ def test_should_allow_valid_urls
'HttP://example.com',
'https://example.com',
'http://räksmörgås.nu', # IDN
- 'http://xn--rksmrgs-5wao1o.nu' # Punycode
+ 'http://xn--rksmrgs-5wao1o.nu', # Punycode
+ 'http://example.com.', # Explicit TLD root period
+ 'http://example.com./foo'
].each do |url|
@model.homepage = url
@model.save
Please sign in to comment.
Something went wrong with that request. Please try again.