Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Default scheme to http when not provided

  • Loading branch information...
commit eac1fe900b9d6aa766c30054d29315c40f71902a 1 parent 14855a8
Kevin Wang and Paul Elliott authored Hashrocket Workstation committed
Showing with 13 additions and 0 deletions.
  1. +1 −0  lib/domainatrix/domain_parser.rb
  2. +12 −0 spec/domainatrix_spec.rb
View
1  lib/domainatrix/domain_parser.rb
@@ -31,6 +31,7 @@ def read_dat_file(file_name)
end
def parse(url)
+ url = "http://#{url}" unless url[/:\/\//]
uri = URI.parse(url)
if uri.query
path = "#{uri.path}?#{uri.query}"
View
12 spec/domainatrix_spec.rb
@@ -13,4 +13,16 @@
Domainatrix.parse("http://foo.bar.pauldix.net").canonical.should == "net.pauldix.bar.foo"
Domainatrix.parse("http://pauldix.co.uk").canonical.should == "uk.co.pauldix"
end
+
+ context 'without a scheme' do
+ subject { Domainatrix.parse('www.pauldix.net') }
+ its(:scheme) { should == 'http' }
+ its(:host) { should == 'www.pauldix.net' }
+ its(:url) { should == 'http://www.pauldix.net' }
+ its(:public_suffix) { should == 'net' }
+ its(:domain) { should == 'pauldix' }
+ its(:subdomain) { should == 'www' }
+ its(:path) { should == '' }
+ its(:domain_with_tld) { should == 'pauldix.net' }
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.