ress 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/ress/subdomain.rb +8 -2
- data/lib/ress/version.rb +1 -1
- data/spec/ress/subdomain_spec.rb +7 -0
- metadata +1 -1
data/lib/ress/subdomain.rb
CHANGED
@@ -62,10 +62,16 @@ module Ress
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def url(protocol, fullpath, subdomain)
|
65
|
-
|
65
|
+
|
66
|
+
fullpath = fullpath[(subdomain.length + 1)..-1] unless subdomain.empty?
|
66
67
|
begin
|
67
68
|
if matches?(subdomain)
|
68
|
-
|
69
|
+
if subdomain.empty?
|
70
|
+
return "#{protocol}#{fullpath}"
|
71
|
+
else
|
72
|
+
return "#{protocol}#{subdomain}.#{fullpath}"
|
73
|
+
end
|
74
|
+
|
69
75
|
end
|
70
76
|
subdomain = subdomain.split('.')[1..-1].join('.')
|
71
77
|
end while(!subdomain.empty?)
|
data/lib/ress/version.rb
CHANGED
data/spec/ress/subdomain_spec.rb
CHANGED
@@ -107,6 +107,13 @@ describe Ress::Subdomain do
|
|
107
107
|
'http://foo.bar.com/some/stuff'
|
108
108
|
end
|
109
109
|
|
110
|
+
it 'can handle empty subdomains' do
|
111
|
+
subdomain = Ress::Subdomain::RegexpSubdomain.new(/^(?!(m|tablet)\.).*$/)
|
112
|
+
subdomain.matches?('').should be_true
|
113
|
+
subdomain.url('http://', 'somewhere.com/some/stuff', '').should ==
|
114
|
+
'http://somewhere.com/some/stuff'
|
115
|
+
end
|
116
|
+
|
110
117
|
end
|
111
118
|
end
|
112
119
|
end
|