rack-canonical_link 0.0.1 → 0.0.2
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/rack-canonical_link.rb
CHANGED
@@ -12,7 +12,8 @@ module Rack
|
|
12
12
|
if env['rack.url_scheme'] != 'https' && (@headers['Content-Type'] =~ /application\/html/ || @headers['Content-Type'] =~ /text\/html/)
|
13
13
|
request = Rack::Request.new env
|
14
14
|
new_body = []
|
15
|
-
|
15
|
+
|
16
|
+
@body.each {|fragement| new_body << fragement.gsub(%r{</head>}, '<link href="' + request.url.gsub(/\/$/,'') + '" rel="canonical" /></head>') }
|
16
17
|
@body = new_body
|
17
18
|
end
|
18
19
|
|
@@ -12,7 +12,7 @@ module Rack
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'should inject canonical tag of http HTML request' do
|
15
|
-
get('/').body.should == '<html><head>Hello world<link href="http://example.org
|
15
|
+
get('/').body.should == '<html><head>Hello world<link href="http://example.org" rel="canonical" /></head><body></body></html>'
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'should not inject canonical tag into non HTML requests for HTTP' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-canonical_link
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-09
|
12
|
+
date: 2013-10-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|