canonical-rails 0.2.9 → 0.2.13

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
  SHA256:
3
- metadata.gz: 0ab1e0b7b6f0b2ab95ac94692939a74ade7bd8a2cb744bec7c6762ae04a1dfe7
4
- data.tar.gz: 8091321b37d368601c5242496bade7282fc2e7a31a4d7ee547cddae8eaa116a6
3
+ metadata.gz: '088a23f4f03053700e7809173d6953067d121ebb1b9ca98b3c5e7a643d4c971a'
4
+ data.tar.gz: 30de872759b0d27df588db3ee600e5a321768526d2fe02d345f94620911d373f
5
5
  SHA512:
6
- metadata.gz: 6015361191325a29ea441f6150277126ba216c59ac40f09954b6b178b497b84216e6783505dafab8b479d4264949836a98d6175101fd275d18b3c941ff7e8022
7
- data.tar.gz: a6bf895a0626fb7dfd47e4bc88c19e2bd90d8671b42c95d5f0878a7578104e9b40af35662806abc442f53d4a2a54e7afea8baa7eca89a5f9e753ee16d8221e33
6
+ metadata.gz: badad29ede7d61cc3f4927e03287fa302b20c0061cfeb242df8e7aac96ac01427511e362ab6282a68638c3fdae8ec8a272b0e773185e5caf233893ac29dd663e
7
+ data.tar.gz: 806a8a41dba749500f6f31b8823342ad4c87ef48be21eb5ed97b2a7dffe7ddc853f19c4621de18d2beef55167c348aee73d6b4ce55c60c56ec1a959614c37547
@@ -20,7 +20,7 @@ module CanonicalRails
20
20
  def path_without_html_extension
21
21
  return '' if request.path == '/'
22
22
 
23
- request.path.sub(/\.html$/, '')
23
+ request.path.sub(/\.html?$/, '')
24
24
  end
25
25
 
26
26
  def canonical_protocol
@@ -38,11 +38,11 @@ module CanonicalRails
38
38
  def canonical_href(host = canonical_host, port = canonical_port, force_trailing_slash = nil)
39
39
  default_ports = { 'https://' => 443, 'http://' => 80 }
40
40
  port = port.present? && port.to_i != default_ports[canonical_protocol] ? ":#{port}" : ''
41
- raw "#{canonical_protocol}#{host}#{port}#{path_without_html_extension}#{trailing_slash_config(force_trailing_slash)}#{whitelisted_query_string}"
41
+ raw "#{canonical_protocol}#{host}#{port}#{path_without_html_extension}#{trailing_slash_config(force_trailing_slash)}#{allowed_query_string}"
42
42
  end
43
43
 
44
44
  def canonical_path(force_trailing_slash = nil)
45
- raw "#{path_without_html_extension}#{trailing_slash_config(force_trailing_slash)}#{whitelisted_query_string}"
45
+ raw "#{path_without_html_extension}#{trailing_slash_config(force_trailing_slash)}#{allowed_query_string}"
46
46
  end
47
47
 
48
48
  def canonical_tag(host = canonical_host, port = canonical_port, force_trailing_slash = nil)
@@ -55,15 +55,15 @@ module CanonicalRails
55
55
  end
56
56
  end
57
57
 
58
- def whitelisted_params
58
+ def allowed_params
59
59
  selected_params = params.select do |key, value|
60
- value.present? && CanonicalRails.sym_whitelisted_parameters.include?(key.to_sym)
60
+ value.present? && CanonicalRails.sym_allowed_parameters.include?(key.to_sym)
61
61
  end
62
62
 
63
63
  selected_params.respond_to?(:to_unsafe_h) ? selected_params.to_unsafe_h : selected_params.to_h
64
64
  end
65
65
 
66
- def whitelisted_query_string
66
+ def allowed_query_string
67
67
  # Rack 1.4.5 fails to handle params that are not strings
68
68
  # So if
69
69
  # my_hash = { "a" => 1, "b" => 2}
@@ -73,10 +73,8 @@ module CanonicalRails
73
73
  # https://github.com/rack/rack/blob/9939d40a5e23dcb058751d1029b794aa2f551900/test/spec_utils.rb#L222
74
74
  # Rack 1.6.0 has it
75
75
  # https://github.com/rack/rack/blob/65a7104b6b3e9ecd8f33c63a478ab9a33a103507/test/spec_utils.rb#L251
76
-
77
- wl_params = whitelisted_params
78
-
79
- "?" + Rack::Utils.build_nested_query(convert_numeric_params(wl_params)) if wl_params.present?
76
+ parameters = allowed_params
77
+ "?" + Rack::Utils.build_nested_query(convert_numeric_params(parameters)) if parameters.present?
80
78
  end
81
79
 
82
80
  private
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/deprecation'
4
+
5
+ module CanonicalRails
6
+ Deprecation = ActiveSupport::Deprecation.new('1.0', 'CanonicalRails')
7
+ end
@@ -1,3 +1,3 @@
1
1
  module CanonicalRails
2
- VERSION = "0.2.9"
2
+ VERSION = "0.2.13"
3
3
  end
@@ -1,4 +1,5 @@
1
1
  require "canonical-rails/engine"
2
+ require "canonical-rails/deprecation"
2
3
 
3
4
  module CanonicalRails
4
5
 
@@ -23,9 +24,13 @@ module CanonicalRails
23
24
  mattr_accessor :collection_actions
24
25
  @@collection_actions = [:index]
25
26
 
27
+ # @deprecated: use config.allowed_parameters instead
26
28
  mattr_accessor :whitelisted_parameters
27
29
  @@whitelisted_parameters = []
28
30
 
31
+ mattr_accessor :allowed_parameters
32
+ @@allowed_parameters = []
33
+
29
34
  mattr_accessor :opengraph_url
30
35
  @@opengraph_url = false
31
36
 
@@ -33,7 +38,12 @@ module CanonicalRails
33
38
  @@sym_collection_actions ||= self.collection_actions.map(&:to_sym)
34
39
  end
35
40
 
36
- def self.sym_whitelisted_parameters
37
- @@sym_whitelisted_parameters ||= self.whitelisted_parameters.map(&:to_sym)
41
+ def self.sym_allowed_parameters
42
+ @@sym_allowed_parameters ||= if self.whitelisted_parameters.empty?
43
+ self.allowed_parameters.map(&:to_sym)
44
+ else
45
+ CanonicalRails::Deprecation.warn('config.whitelisted_parameters is deprecated, please use config.allowed_parameters instead.')
46
+ self.whitelisted_parameters.map(&:to_sym)
47
+ end
38
48
  end
39
49
  end
@@ -20,9 +20,9 @@ CanonicalRails.setup do |config|
20
20
  config.collection_actions# = [:index]
21
21
 
22
22
  # Parameter spamming can cause index dilution by creating seemingly different URLs with identical or near-identical content.
23
- # Unless whitelisted, these parameters will be omitted
23
+ # Unless allowed, these parameters will be omitted
24
24
 
25
- config.whitelisted_parameters# = []
25
+ config.allowed_parameters# = []
26
26
 
27
27
  # Output a matching OpenGraph URL meta tag (og:url) with the canonical URL, as recommended by Facebook et al
28
28
  config.opengraph_url#= true
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.9
4
+ version: 0.2.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Ivanov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-20 00:00:00.000000000 Z
11
+ date: 2021-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -17,9 +17,9 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '4.1'
20
- - - "<"
20
+ - - "<="
21
21
  - !ruby/object:Gem::Version
22
- version: '6.1'
22
+ version: '7.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -27,9 +27,9 @@ dependencies:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
29
  version: '4.1'
30
- - - "<"
30
+ - - "<="
31
31
  - !ruby/object:Gem::Version
32
- version: '6.1'
32
+ version: '7.0'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: appraisal
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -64,14 +64,14 @@ dependencies:
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '3.5'
67
+ version: 4.0.1
68
68
  type: :development
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '3.5'
74
+ version: 4.0.1
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: pry
77
77
  requirement: !ruby/object:Gem::Requirement
@@ -101,13 +101,15 @@ files:
101
101
  - app/helpers/canonical_rails/tag_helper.rb
102
102
  - config/routes.rb
103
103
  - lib/canonical-rails.rb
104
+ - lib/canonical-rails/deprecation.rb
104
105
  - lib/canonical-rails/engine.rb
105
106
  - lib/canonical-rails/version.rb
106
107
  - lib/generators/canonical_rails/install/install_generator.rb
107
108
  - lib/generators/canonical_rails/install/templates/canonical_rails.rb
108
109
  - lib/tasks/canonical-rails_tasks.rake
109
110
  homepage: https://github.com/jumph4x/canonical-rails
110
- licenses: []
111
+ licenses:
112
+ - MIT
111
113
  metadata: {}
112
114
  post_install_message:
113
115
  rdoc_options: []
@@ -124,8 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
126
  - !ruby/object:Gem::Version
125
127
  version: '0'
126
128
  requirements: []
127
- rubyforge_project:
128
- rubygems_version: 2.7.6.2
129
+ rubygems_version: 3.0.3
129
130
  signing_key:
130
131
  specification_version: 4
131
132
  summary: Simple and configurable Rails canonical ref tag helper