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 +4 -4
- data/app/helpers/canonical_rails/tag_helper.rb +15 -6
- data/lib/canonical-rails/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ccf0cfb2c475521e6fab106de4ef2e322a1cf4d87038495d5564563a15acd373
|
4
|
+
data.tar.gz: 0b11fbf7641ac94bbc1a74de4c15cc3d0e56ebc39720b027ad4a9d69f2c8e206
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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}#{
|
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}#{
|
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)
|
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.
|
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:
|
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:
|
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
|