ress 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
 
@@ -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
- if subdomain.empty?
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
@@ -1,3 +1,3 @@
1
1
  module Ress
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -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
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: ress
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.8
5
+ version: 0.0.9
6
6
  platform: ruby
7
7
  authors:
8
8
  - Matthew Robertson