canonical-rails 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eea720f9f6caad4bc34837f6a2265b4bc0673afe
4
- data.tar.gz: d2566cf14a31c3253685eb102358957c7c055d9c
3
+ metadata.gz: c18700d23c45f68b450a9da262f88e7524a0388c
4
+ data.tar.gz: 278eda8035516a953b73b54cac15c5a7428c0523
5
5
  SHA512:
6
- metadata.gz: 0479b71bbcfc0933ca238027f6d9881e51068c6a6d843a746ac6cbc9f993b2e692c0267da371814bd3ccb4587744bdb7bb9e3179b52dfbe16d11b83821062a39
7
- data.tar.gz: b7845f8a3313244ba9692c5dd88966a5883e68d0cbef6ac2efc419b99758a4b6d3328d06abb520b4306619eb2a925a92b78792340caaea38ddd048f06bb9be80
6
+ metadata.gz: 054e6ed7f57e857cc5b7bd9b93756d937f46a819acabc13211fefb62216a040e830cc1ab4a80b2ccc2787f5dc7333492a44ef9441105f8ff405dfc9cb50fadc4
7
+ data.tar.gz: 304915f4ed28c27353ad2dcde5ae5f06061c7c6189888cf27c95320eb305aa8c2395dfb3ad8da488f5dad9d839a8f4003283d97818be2ca3c7c20d7413d6a82f
@@ -1,10 +1,10 @@
1
1
  module CanonicalRails
2
2
  module TagHelper
3
-
3
+
4
4
  def trailing_slash_needed?
5
5
  CanonicalRails.sym_collection_actions.include? request.params['action'].to_sym
6
6
  end
7
-
7
+
8
8
  def trailing_slash_if_needed
9
9
  "/" if trailing_slash_needed? and request.path != '/'
10
10
  end
@@ -12,28 +12,28 @@ module CanonicalRails
12
12
  def path_without_html_extension
13
13
  request.path.sub(/\.html$/, '')
14
14
  end
15
-
15
+
16
16
  def canonical_host
17
17
  CanonicalRails.host || request.host
18
18
  end
19
-
19
+
20
20
  def canonical_href(host=canonical_host)
21
21
  "#{request.protocol}#{host}#{path_without_html_extension}#{trailing_slash_if_needed}#{whitelisted_query_string}"
22
22
  end
23
-
23
+
24
24
  def canonical_tag(host=canonical_host)
25
- tag(:link, :href => canonical_href(host), :rel => 'canonical')
25
+ tag(:link, :href => raw(canonical_href(host)), :rel => 'canonical')
26
26
  end
27
-
27
+
28
28
  def whitelisted_params
29
29
  request.params.select do |key, value|
30
30
  value.present? and
31
31
  CanonicalRails.sym_whitelisted_parameters.include? key.to_sym
32
32
  end
33
33
  end
34
-
34
+
35
35
  def whitelisted_query_string
36
- "?#{whitelisted_params.to_a.join('=')}" if whitelisted_params.present?
36
+ "?#{whitelisted_params.map{ |key, val| "#{key}=#{val}" }.join('&')}" if whitelisted_params.present?
37
37
  end
38
38
  end
39
39
  end
@@ -1,3 +1,3 @@
1
1
  module CanonicalRails
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canonical-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Ivanov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-10 00:00:00.000000000 Z
11
+ date: 2014-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails