ruby-link-checker 0.6.0 → 0.6.1

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: 5797b1459b6dfe9254188079c8940286e4b49437808cf5f74b11f6423f2d5677
4
- data.tar.gz: b2cfb5abb84a0226f1067f74ecaeef5152a3b5c697ad8962b9503f57854f0f4a
3
+ metadata.gz: d39534bd64245b18ca425097d7ee4dbe9946cbddc32e25bfe8928c8210b50735
4
+ data.tar.gz: e3732fd4400612e1b67458e20772fcf67ce1c4b3134fd555a63aebcefb458ac8
5
5
  SHA512:
6
- metadata.gz: 546bc8134e07bab2f58bc50ea3fe9f60e2f79252301b41321ca4b08b4c8600c646da30907b742fffb2f8af46e24fa8531ccd4c969bef3575fbe33872acd8c765
7
- data.tar.gz: 3894bcd493c8ea47b894f22293ab04ffe347333eb96e974df2ce9cc8082cd046742ad2e48a31e6a0c43a6cb2de748f73fec6dd74bc58f0f6516975bd644e302d
6
+ metadata.gz: '09b1ba24a8340d78c998503acc0fb7c9e54309b070a42a87ec03b4f7a8889f5a34777562896dead599728acf2a669a376c56c774c3d89f01cd648d973ac0b2b5'
7
+ data.tar.gz: cd7a8b47ed981eee09db624f2f25647a70634f617942db0a841973fa87200223e32d6b7f2f971e66aed13c59a6c288e554c89d71dde87d16b541f8a137c73f4b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 0.6.1 (2026/11/23)
2
+
3
+ * [#56](https://github.com/dblock/ruby-link-checker/pull/56): Fixed `host_headers` invalidating cached results for every URL; only URLs whose headers changed are rechecked - [@dblock](https://github.com/dblock).
4
+
1
5
  ### 0.6.0 (2026/11/22)
2
6
 
3
7
  * [#31](https://github.com/dblock/ruby-link-checker/pull/31): Updated ruby-gem-release to 0.5.0 - [@dblock](https://github.com/dblock), [@Copilot](https://github.com/Copilot).
data/README.md CHANGED
@@ -1,7 +1,4 @@
1
- <picture>
2
- <source media="(prefers-color-scheme: dark)" srcset="assets/wordmark-dark.svg">
3
- <img alt="ruby-link-checker" src="assets/wordmark.svg" width="375">
4
- </picture>
1
+ <img alt="ruby-link-checker" src="assets/logo.svg" width="128">
5
2
 
6
3
  Fast Ruby Link Checker
7
4
  ======================
@@ -454,7 +451,7 @@ checker = LinkChecker::Typhoeus::Hydra::Checker.new(
454
451
  )
455
452
  ```
456
453
 
457
- Host headers are chosen for each request from that request's own host, including every redirect hop, so a token configured for one host is never sent to a different host that it redirects to. Global `headers` are sent to every host, including redirect targets. Host headers are part of the [deduplication](#deduplication) and [caching](#caching) identity, and so are their values: the cache file stores a hash of them, not the values themselves.
454
+ Host headers are chosen for each request from that request's own host, including every redirect hop, so a token configured for one host is never sent to a different host that it redirects to. Global `headers` are sent to every host, including redirect targets. The headers sent for a URL, global headers merged with its matching host headers, are part of its [deduplication](#deduplication) and [caching](#caching) identity: the cache file stores a hash of them, not the values themselves. Changing the host headers of one host only invalidates cached results for the URLs on the hosts it matches.
458
455
 
459
456
  ### Global Configuration
460
457
 
@@ -84,15 +84,7 @@ module LinkChecker
84
84
  # Request headers for uri: the user-agent, then global headers, then every matching host_headers entry.
85
85
  # Later values replace earlier ones with the same case-insensitive name.
86
86
  def request_headers_for(uri)
87
- host = _host_key(uri)
88
- sources = [{ 'User-Agent' => user_agent }, headers]
89
- sources += host_headers.filter_map { |pattern, values| values if host && _host_match?(pattern, host) }
90
- sources.each_with_object({}) do |values, merged|
91
- values.each do |name, value|
92
- merged.delete_if { |existing, _value| existing.casecmp?(name.to_s) }
93
- merged[name.to_s] = value
94
- end
95
- end
87
+ _merge_headers([{ 'User-Agent' => user_agent }, headers] + _matching_host_headers(uri))
96
88
  end
97
89
 
98
90
  # The host that per-host limits apply to, or nil when the URI has none.
@@ -150,9 +142,21 @@ module LinkChecker
150
142
  prune_cache! if @cache_store&.prune?
151
143
  end
152
144
 
153
- def _host_headers_identity
154
- host_headers.map do |pattern, values|
155
- [pattern.is_a?(Regexp) ? pattern.inspect : pattern, values.sort_by { |key, _value| key.to_s }]
145
+ # The host_headers values that apply to uri, in configuration order.
146
+ def _matching_host_headers(uri)
147
+ host = _host_key(uri)
148
+ return [] unless host
149
+
150
+ host_headers.filter_map { |pattern, values| values if _host_match?(pattern, host) }
151
+ end
152
+
153
+ # Merges header hashes in order; later values replace earlier ones with the same case-insensitive name.
154
+ def _merge_headers(sources)
155
+ sources.each_with_object({}) do |values, merged|
156
+ values.each do |name, value|
157
+ merged.delete_if { |existing, _value| existing.casecmp?(name.to_s) }
158
+ merged[name.to_s] = value
159
+ end
156
160
  end
157
161
  end
158
162
 
@@ -226,9 +230,9 @@ module LinkChecker
226
230
  attributes = Config::ATTRIBUTES - IDENTITY_EXCLUDED_ATTRIBUTES
227
231
  attributes += %i[timeout connecttimeout read_timeout open_timeout protocol].select { |key| respond_to?(key) }
228
232
  settings = attributes.to_h { |key| [key, send(key)] }
229
- settings[:headers] = headers.sort_by { |key, _value| key.to_s }
233
+ # Only the headers sent for this URL are part of its identity, so changing the headers of other hosts keeps it.
234
+ settings[:headers] = _merge_headers([headers] + _matching_host_headers(parsed)).sort_by { |key, _value| key }
230
235
  settings.delete(:host_headers)
231
- settings[:host_headers] = _host_headers_identity if host_headers.any?
232
236
  Digest::SHA256.hexdigest(JSON.generate([task_klass.name, parsed.to_s, settings]))
233
237
  rescue URI::InvalidURIError, JSON::GeneratorError, TypeError
234
238
  nil
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LinkChecker
4
- VERSION = '0.6.0'
4
+ VERSION = '0.6.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-link-checker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Doubrovkine