canonical-rails 0.2.6 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 38067fe7096258dd5090045db04194d4ab089758ebcda87b3863011535893d7e
4
- data.tar.gz: 16567396612642f5640dc28dc45c65be6702bb1a37389e2d200d52987ef2fea0
3
+ metadata.gz: ccf0cfb2c475521e6fab106de4ef2e322a1cf4d87038495d5564563a15acd373
4
+ data.tar.gz: 0b11fbf7641ac94bbc1a74de4c15cc3d0e56ebc39720b027ad4a9d69f2c8e206
5
5
  SHA512:
6
- metadata.gz: ac96b6a583c455be2407383812ab84bf0670a51cf8debc17c435997a8f66f976b6b2ff4274ca1b539ef3e3079f0d42d0932b90a7b29cdf36fbce61da58ade1fb
7
- data.tar.gz: 5347b6cf1356f000144da898cd8d5ddb78bba658cbf3ef35d40a270174d202b7a06a61e70bb51d7b8abe70c8ae86739e6c11c887cbd33feeea1a1c198bdb9480
6
+ metadata.gz: 7b774522cf2cb5dced126ddc7d78cf918fef84f6e7144526b9be4d041fa845923a04ace457671d4ba22014eabe6f24a4fcae9f876070a14252353a6590b74743
7
+ data.tar.gz: 764aa02083b5346fa21aae3691b055286efd19a2a587853e5a58e8cc3dfe748594306e8bc6da8f3995ce8f8bbfa808d622550b4672f83e145689c00f56f59324
@@ -4,6 +4,15 @@ module CanonicalRails
4
4
  request.params.key?('action') && CanonicalRails.sym_collection_actions.include?(request.params['action'].to_sym)
5
5
  end
6
6
 
7
+ # Leave force_trailing_slash as nil to get the original behavior of trailing_slash_if_needed
8
+ def trailing_slash_config(force_trailing_slash = nil)
9
+ if force_trailing_slash
10
+ "/"
11
+ elsif force_trailing_slash.nil?
12
+ trailing_slash_if_needed
13
+ end
14
+ end
15
+
7
16
  def trailing_slash_if_needed
8
17
  "/" if trailing_slash_needed?
9
18
  end
@@ -26,18 +35,18 @@ module CanonicalRails
26
35
  (CanonicalRails.port || request.port).to_i
27
36
  end
28
37
 
29
- def canonical_href(host = canonical_host, port = canonical_port)
38
+ def canonical_href(host = canonical_host, port = canonical_port, force_trailing_slash = nil)
30
39
  default_ports = { 'https://' => 443, 'http://' => 80 }
31
40
  port = port.present? && port.to_i != default_ports[canonical_protocol] ? ":#{port}" : ''
32
- raw "#{canonical_protocol}#{host}#{port}#{path_without_html_extension}#{trailing_slash_if_needed}#{whitelisted_query_string}"
41
+ raw "#{canonical_protocol}#{host}#{port}#{path_without_html_extension}#{trailing_slash_config(force_trailing_slash)}#{whitelisted_query_string}"
33
42
  end
34
43
 
35
- def canonical_path
36
- raw "#{path_without_html_extension}#{trailing_slash_if_needed}#{whitelisted_query_string}"
44
+ def canonical_path(force_trailing_slash = nil)
45
+ raw "#{path_without_html_extension}#{trailing_slash_config(force_trailing_slash)}#{whitelisted_query_string}"
37
46
  end
38
47
 
39
- def canonical_tag(host = canonical_host, port = canonical_port)
40
- canonical_url = canonical_href(host, port)
48
+ def canonical_tag(host = canonical_host, port = canonical_port, force_trailing_slash = nil)
49
+ canonical_url = canonical_href(host, port, force_trailing_slash)
41
50
  capture do
42
51
  if CanonicalRails.opengraph_url
43
52
  concat tag(:meta, property: 'og:url', content: canonical_url)
@@ -1,3 +1,3 @@
1
1
  module CanonicalRails
2
- VERSION = "0.2.6"
2
+ VERSION = "0.2.8"
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.2.6
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Ivanov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-25 00:00:00.000000000 Z
11
+ date: 2020-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -45,19 +45,19 @@ dependencies:
45
45
  - !ruby/object:Gem::Version
46
46
  version: '0'
47
47
  - !ruby/object:Gem::Dependency
48
- name: sqlite3
48
+ name: sprockets
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - ">="
51
+ - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '0'
53
+ version: '3.0'
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - ">="
58
+ - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '0'
60
+ version: '3.0'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rspec-rails
63
63
  requirement: !ruby/object:Gem::Requirement