addressabler 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.markdown +39 -0
- data/lib/addressabler/query.rb +23 -0
- data/lib/addressabler.rb +80 -0
- data/lib/tlds +3824 -0
- data/spec/addressabler_spec.rb +46 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/uri_spec.rb +4210 -0
- metadata +107 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'addressabler'
|
2
|
+
|
3
|
+
describe Addressabler do
|
4
|
+
it "should still let me parse a URI" do
|
5
|
+
uri = Addressable::URI.parse("http://www.google.com/path?foo=bar#anchor")
|
6
|
+
uri.should be_instance_of(Addressable::URI)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should get the scheme of a URI" do
|
10
|
+
uri = Addressable::URI.parse("http://www.google.com/path?foo=bar#anchor")
|
11
|
+
uri.scheme.should == "http"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should support a TLD" do
|
15
|
+
uri = Addressable::URI.parse("http://www.google.com/path?foo=bar#anchor")
|
16
|
+
uri.tld.should == 'com'
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should support wonky TLDs" do
|
20
|
+
uri = Addressable::URI.parse("http://www.foo.bar.baz.co.uk/gjadgsg#sdgs?adg=f")
|
21
|
+
uri.tld.should == 'co.uk'
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should support adding keys to the query" do
|
25
|
+
uri = Addressable::URI.parse("http://www.foo.bar.baz.co.uk/gjadgsg?adg=f")
|
26
|
+
uri.query_hash.should == {'adg' => 'f'}
|
27
|
+
uri.query_hash[:foo] = "bar"
|
28
|
+
uri.to_s.should == "http://www.foo.bar.baz.co.uk/gjadgsg?adg=f&foo=bar"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should support adding nested values to the query" do
|
32
|
+
uri = Addressable::URI.parse("http://www.amazon.ca")
|
33
|
+
uri.query_hash[:foo] = {:bar => :baz}
|
34
|
+
uri.to_s.should == "http://www.amazon.ca?foo[bar]=baz"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should support subdomains" do
|
38
|
+
uri = Addressable::URI.heuristic_parse("i.am.a.subdomain.co.uk")
|
39
|
+
uri.subdomain.should == "i.am.a"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should support domains" do
|
43
|
+
uri = Addressable::URI.heuristic_parse("i.am.a.subdomain.co.uk")
|
44
|
+
uri.domain.should == "subdomain"
|
45
|
+
end
|
46
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'rspec/autorun'
|