Skip to content
Browse files

Add support for Url#domain_with_public_suffix

* includes alias for domain_with_tld
* includes specs
* didn't actually run the specs :D
  • Loading branch information...
1 parent 1416b8b commit 3655c2ceb5523dcc448d40b80b8b6031240d4059 @mtodd mtodd committed Mar 3, 2011
Showing with 19 additions and 0 deletions.
  1. +6 −0 lib/domainatrix/url.rb
  2. +13 −0 spec/domainatrix/url_spec.rb
View
6 lib/domainatrix/url.rb
@@ -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
View
13 spec/domainatrix/url_spec.rb
@@ -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 3655c2c

Please sign in to comment.
Something went wrong with that request. Please try again.