ress 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ress/canonical_version.rb +0 -1
- data/lib/ress/subdomain.rb +8 -11
- data/lib/ress/version.rb +1 -1
- data/spec/ress/subdomain_spec.rb +3 -3
- metadata +1 -1
@@ -13,7 +13,6 @@ module Ress
|
|
13
13
|
# Create a tag of this format:
|
14
14
|
# `<link rel="canonical" href="http://www.example.com/page-1" >`
|
15
15
|
def link_tag(protocol, fullpath, req_subdomain, view)
|
16
|
-
|
17
16
|
view.tag :link, :rel => 'canonical', :href => url(protocol, fullpath, req_subdomain)
|
18
17
|
end
|
19
18
|
|
data/lib/ress/subdomain.rb
CHANGED
@@ -62,21 +62,18 @@ module Ress
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def url(protocol, fullpath, subdomain)
|
65
|
-
|
66
65
|
fullpath = fullpath[(subdomain.length + 1)..-1] unless subdomain.empty?
|
67
66
|
begin
|
68
|
-
if matches?(subdomain)
|
69
|
-
|
70
|
-
return "#{protocol}#{fullpath}"
|
71
|
-
else
|
72
|
-
return "#{protocol}#{subdomain}.#{fullpath}"
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|
76
|
-
subdomain = subdomain.split('.')[1..-1].join('.')
|
77
|
-
end while(!subdomain.empty?)
|
67
|
+
return build_url(protocol, subdomain, fullpath) if matches?(subdomain)
|
68
|
+
end while( subdomain.slice!(/^[^\.]+\.?/) )
|
78
69
|
end
|
79
70
|
|
71
|
+
private
|
72
|
+
|
73
|
+
def build_url(protocol, subdomain, fullpath)
|
74
|
+
subdomain.empty? ? "#{protocol}#{fullpath}" : "#{protocol}#{subdomain}.#{fullpath}"
|
75
|
+
end
|
76
|
+
|
80
77
|
end
|
81
78
|
|
82
79
|
end
|
data/lib/ress/version.rb
CHANGED
data/spec/ress/subdomain_spec.rb
CHANGED
@@ -108,10 +108,10 @@ describe Ress::Subdomain do
|
|
108
108
|
end
|
109
109
|
|
110
110
|
it 'can handle empty subdomains' do
|
111
|
-
subdomain = Ress::Subdomain::RegexpSubdomain.new(/^(?!(m|tablet)
|
111
|
+
subdomain = Ress::Subdomain::RegexpSubdomain.new(/^(?!(m|tablet)).*$/)
|
112
112
|
subdomain.matches?('').should be_true
|
113
|
-
subdomain.url('http://', 'somewhere.com/some/stuff', '').should
|
114
|
-
'http://somewhere.com/some/stuff'
|
113
|
+
subdomain.url('http://', 'somewhere.com/some/stuff', '').should eq 'http://somewhere.com/some/stuff'
|
114
|
+
subdomain.url('http://', 'm.somewhere.com/some/stuff', 'm').should eq 'http://somewhere.com/some/stuff'
|
115
115
|
end
|
116
116
|
|
117
117
|
end
|