twingly-url 7.1.1 → 7.2.0

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: 546297fb93a4c8c81ddeae25c27ed9cd174ac4f13df0aae03287ab94f831be6b
4
- data.tar.gz: 10e53871ab61298b9d1bc219e12b593b0696b4be419d00155317d1d1f3b8e229
3
+ metadata.gz: 16fcff7c103b60cfa97ceb0c75ac90846b2b30728914ebb460aaddf012287910
4
+ data.tar.gz: bb20f24348a1379b8d2b318f7e63297dd45ae4657f1fe426c8fb90bbbd91f34f
5
5
  SHA512:
6
- metadata.gz: 81a743b883a0c5f2f25628566002f646074fcd68f1473ccbd327dd82766bc8e645676cf9a3bfeeed23a7676ff4a1f4522d7b6407d93a55ad73ac3c6ddd1f9b4a
7
- data.tar.gz: bbb6e7694dbad697653c15205ac2049c8f3ce6f90d338fe7f4634937478da54c63a1504975db4273af1fd36199896c13e232c2d9c01f908b9186f4d11f2003fe
6
+ metadata.gz: 1c5796d510ece7e0641048a4e266b234e592e052e92a2c8984425d164d91a216819d4baeca31b8433812badcb32d7fa275e8b1daa20e90c36b4a58ed32da2b92
7
+ data.tar.gz: 18899572fdf358b11a9efd08738b5dd4bd230550d4ca7925b2b8893c0f7810a10df3a360f609f16600fa7e6cbf2d07f084edd04c7d45c9b92bf69ebd70bc528e
data/README.md CHANGED
@@ -17,6 +17,7 @@ Twingly URL tools.
17
17
  * `Twingly::URL::Extended.normalize_and_calculate_urlhash(url, addressable_normalize: false)` - Returns a `HashResult` struct with `url` (original URL minus blacklisted parameters), `callable_url` (original URL canonicalized with `Addressable::URI#normalize`, minus blacklisted parameters), `normalized_url` (scheme-less), `urlhash` (`documentdb_hash` of the normalized URL, as a `String`) and `legacy_urlhash` (same digest with the scheme kept)
18
18
  * `addressable_normalize: true` applies `Addressable::URI#normalize` (percent-encoding, case, default port and dot segments) before the extended normalization, so `normalized_url` and both hashes are calculated from the canonical form
19
19
  * `Twingly::URL::Extended#addressable_normalized` - Returns a new instance canonicalized with `Addressable::URI#normalize`, `#normalized(addressable_normalize: true)` is the extended normalization applied to that instance
20
+ * `Twingly::URL::Extended#callable_url` - The addressable normalized URL minus blacklisted parameters
20
21
 
21
22
  ## Getting Started
22
23
 
@@ -67,10 +67,14 @@ module Twingly
67
67
  self.class.send(:new, addressable_normalized_url, public_suffix_domain)
68
68
  end
69
69
 
70
+ def callable_url
71
+ addressable_normalized.original_url_without_blacklisted_parameters
72
+ end
73
+
70
74
  def original_url_without_blacklisted_parameters
71
75
  url = addressable_uri.dup
72
76
  url.path = without_blacklisted_matrix_parameters(addressable_uri.path)
73
- url.query_values = without_blacklisted_query_parameters(addressable_uri.query_values)
77
+ url.query = without_blacklisted_query_string(addressable_uri.query)
74
78
  url.to_s
75
79
  end
76
80
 
@@ -118,6 +122,19 @@ module Twingly
118
122
  values_without_blacklisted_params
119
123
  end
120
124
 
125
+ def without_blacklisted_query_string(query)
126
+ return if query.nil?
127
+
128
+ kept = query.split("&").reject do |pair|
129
+ next true if pair.empty?
130
+
131
+ name = Addressable::URI.unencode_component(pair.split("=", 2).first)
132
+ BLACKLISTED_QUERY_PARAMETERS.include?(name)
133
+ end
134
+
135
+ kept.join("&") unless kept.empty?
136
+ end
137
+
121
138
  def without_blacklisted_matrix_parameters(path)
122
139
  # No need to run gsub if there are no matrix parameters
123
140
  return path unless path.include?(";")
@@ -16,6 +16,26 @@ module Twingly
16
16
  self
17
17
  end
18
18
 
19
+ def addressable_normalized
20
+ self
21
+ end
22
+
23
+ def callable_url
24
+ ""
25
+ end
26
+
27
+ def original_url_without_blacklisted_parameters
28
+ ""
29
+ end
30
+
31
+ def query
32
+ nil
33
+ end
34
+
35
+ def query_values
36
+ nil
37
+ end
38
+
19
39
  def valid?
20
40
  false
21
41
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Twingly
4
4
  class URL
5
- VERSION = "7.1.1"
5
+ VERSION = "7.2.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twingly-url
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.1.1
4
+ version: 7.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Twingly AB
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-09-15 00:00:00.000000000 Z
11
+ date: 2026-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable