Permalink
Browse files

Merge branch 'domain-with-tld' of https://github.com/mtodd/domainatrix

…into mtodd-domain-with-tld
  • Loading branch information...
Paul Dix
Paul Dix committed Apr 8, 2011
2 parents 52244ea + 3655c2c commit 7b72bd623a4e84255ef9a48b7e8ace6bea521072
Showing with 19 additions and 0 deletions.
  1. +6 −0 lib/domainatrix/url.rb
  2. +13 −0 spec/domainatrix/url_spec.rb
View
@@ -23,5 +23,11 @@ def canonical(options = {})
url
end
+
+ def domain_with_public_suffix
+ "#{@domain}.#{@public_suffix}"
+ end
+ alias domain_with_tld domain_with_public_suffix
+
end
end
@@ -38,4 +38,17 @@
it "canonicalizes the url without the path" do
Domainatrix::Url.new(:subdomain => "foo", :domain => "pauldix", :public_suffix => "net").canonical(:include_path => false).should == "net.pauldix.foo"
end
+
+ it "combines the domain with the public_suffix" do
+ Domainatrix::Url.new(:domain => "pauldix", :public_suffix => "net").domain_with_public_suffix.should == "pauldix.net"
+ Domainatrix::Url.new(:domain => "foo", :public_suffix => "co.uk" ).domain_with_public_suffix.should == "foo.co.uk"
+ Domainatrix::Url.new(:subdomain => "baz", :domain => "bar", :public_suffix => "com").domain_with_public_suffix.should == "bar.com"
+ end
+
+ it "combines the domain with the public_suffix as an alias" do
+ Domainatrix::Url.new(:domain => "pauldix", :public_suffix => "net").domain_with_tld.should == "pauldix.net"
+ Domainatrix::Url.new(:domain => "foo", :public_suffix => "co.uk" ).domain_with_tld.should == "foo.co.uk"
+ Domainatrix::Url.new(:subdomain => "baz", :domain => "bar", :public_suffix => "com").domain_with_tld.should == "bar.com"
+ end
+
end

0 comments on commit 7b72bd6

Please sign in to comment.