html-proofer 5.0.8 → 5.0.9

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: c2c4f6e223ea64d009b2dc422066610376bfff66fa8b6da09b485ce72e5538c7
4
- data.tar.gz: e9f2d8f81a4f21e5bb76bbaaedd7e8a95b95cf6439938e62c364ad92392af518
3
+ metadata.gz: d9ed4a509a2d120a3aff5ad4809f6b91feff3842dceb371015aca5fd08e69bb2
4
+ data.tar.gz: 0db88e877a8fc19022d4fd1f382e4d38bfeead1540c42817e33799ccf2527bc7
5
5
  SHA512:
6
- metadata.gz: 70fa1c406f6bf212176f2e2f257c98e88615635463d584e01e31a8be2647b096e8ebfb75549058a9626185f8f45989e446e28d9977a4d14189d074a4d6c75b9c
7
- data.tar.gz: 31ea3bb4397972ade2731a442ad4cae5a435ad13f598777b2890c179f54a2f54f7d2102fb46ac805fc39bb0b8e7efe8805c61cf1fc63d8f897158caa732a6bde
6
+ metadata.gz: 6c888e7975c91eb41124057eba57fb3bdd9f8d82f38be6958c82649458526d7a41cb9aac8d4221678c273db419708cb2abfce2ce0be7396acd2b97295e938844
7
+ data.tar.gz: 61acc2e9c73ba8ca51abca84e21524e145a3f98f8d0d8db4c9683d13407610ea13dfe04342cc861ca0109cd8f9ac1fa24300bb0df684a198787ee5a2d40c8cde
@@ -52,7 +52,8 @@ module HTMLProofer
52
52
 
53
53
  def ignore?
54
54
  return true if /^javascript:/.match?(@url)
55
- return true if ignores_pattern?(@runner.options[:ignore_urls])
55
+
56
+ true if ignores_pattern?(@runner.options[:ignore_urls])
56
57
  end
57
58
 
58
59
  def valid?
@@ -220,11 +221,24 @@ module HTMLProofer
220
221
  @url.to_s.sub(/##{hash}/, "")
221
222
  end
222
223
 
223
- # catch any obvious issues, like strings in port numbers
224
+ # catch any obvious issues
224
225
  private def clean_url!
225
- return if @url =~ /^([!#{Regexp.last_match(0)}-;=?-\[\]_a-z~]|%[0-9a-fA-F]{2})+$/
226
-
227
- @url = Addressable::URI.parse(@url).normalize.to_s
226
+ parsed_url = Addressable::URI.parse(@url)
227
+ url = if parsed_url.scheme.nil?
228
+ parsed_url
229
+ else
230
+ parsed_url.normalize
231
+ end.to_s
232
+
233
+ # normalize strips this off, which causes issues with cache
234
+ @url = if @url.end_with?("/") && !url.end_with?("/")
235
+ "#{url}/"
236
+ elsif !@url.end_with?("/") && url.end_with?("/")
237
+ url.chop
238
+ else
239
+ url
240
+ end
241
+ rescue Addressable::URI::InvalidURIError # rubocop:disable Lint/SuppressedException; error will be reported at check time
228
242
  end
229
243
 
230
244
  private def swap_urls!
@@ -41,7 +41,7 @@ module HTMLProofer
41
41
  end
42
42
 
43
43
  def parsed_timeframe(timeframe)
44
- return nil if timeframe.nil?
44
+ return if timeframe.nil?
45
45
 
46
46
  time, date = timeframe.match(/(\d+)(\D)/).captures
47
47
  time = time.to_i
@@ -252,7 +252,7 @@ module HTMLProofer
252
252
  SECONDS_PER_HOUR = 3600
253
253
  SECONDS_PER_DAY = 86400
254
254
  SECONDS_PER_WEEK = 604800
255
- SECONDS_PER_MONTH = 2629746 # 1/12 of a gregorian year
255
+ SECONDS_PER_MONTH = 2629746 # 1/12 of a gregorian year
256
256
 
257
257
  private def time_ago(measurement, unit)
258
258
  case unit
@@ -269,7 +269,8 @@ module HTMLProofer
269
269
 
270
270
  private def url_matches_type?(url, type)
271
271
  return true if type == :internal && url !~ URI_REGEXP
272
- return true if type == :external && url =~ URI_REGEXP
272
+
273
+ true if type == :external && url =~ URI_REGEXP
273
274
  end
274
275
 
275
276
  private def cleaned_url(url)
@@ -233,8 +233,8 @@ module HTMLProofer
233
233
  arg.split(",").each_with_object({}) do |s, hsh|
234
234
  split = s.split(/(?<!\\):/, 2)
235
235
 
236
- re = split[0].gsub(/\\:/, ":")
237
- string = split[1].gsub(/\\:/, ":")
236
+ re = split[0].gsub("\\:", ":")
237
+ string = split[1].gsub("\\:", ":")
238
238
  hsh[Regexp.new(re)] = string
239
239
  end
240
240
  end
@@ -27,7 +27,7 @@ module HTMLProofer
27
27
  end
28
28
 
29
29
  def meta_content
30
- return nil unless meta_tag?
30
+ return unless meta_tag?
31
31
 
32
32
  @node["content"]
33
33
  end
@@ -37,7 +37,7 @@ module HTMLProofer
37
37
  end
38
38
 
39
39
  def src
40
- return nil if !img_tag? && !script_tag? && !source_tag?
40
+ return if !img_tag? && !script_tag? && !source_tag?
41
41
 
42
42
  @node["src"]
43
43
  end
@@ -51,7 +51,7 @@ module HTMLProofer
51
51
  end
52
52
 
53
53
  def srcset
54
- return nil if !img_tag? && !source_tag?
54
+ return if !img_tag? && !source_tag?
55
55
 
56
56
  @node["srcset"]
57
57
  end
@@ -61,7 +61,7 @@ module HTMLProofer
61
61
  end
62
62
 
63
63
  def href
64
- return nil if !a_tag? && !link_tag?
64
+ return if !a_tag? && !link_tag?
65
65
 
66
66
  @node["href"]
67
67
  end
@@ -96,7 +96,7 @@ module HTMLProofer
96
96
  IMAGE_CANDIDATE_REGEX = /\s*([^,]\S*[^,](?:\s+[^,]+)?)\s*(?:,|$)/
97
97
 
98
98
  def srcsets
99
- return nil if blank?(srcset)
99
+ return if blank?(srcset)
100
100
 
101
101
  srcset.split(IMAGE_CANDIDATE_REGEX).select.with_index do |_part, idx|
102
102
  idx.odd?
@@ -112,7 +112,7 @@ module HTMLProofer
112
112
  end
113
113
 
114
114
  def srcsets_wo_sizes
115
- return nil if blank?(srcsets)
115
+ return if blank?(srcsets)
116
116
 
117
117
  srcsets.map do |srcset|
118
118
  srcset.split(" ").first
@@ -133,7 +133,7 @@ module HTMLProofer
133
133
 
134
134
  attrs = @runner.options[:swap_attributes][@node.name]
135
135
 
136
- return true unless blank?(attrs)
136
+ true unless blank?(attrs)
137
137
  end
138
138
 
139
139
  private def swap_attributes!
@@ -41,8 +41,8 @@ module HTMLProofer
41
41
  :red
42
42
  end
43
43
 
44
- if (STDOUT_LEVELS.include?(level) && $stdout.isatty) ||
45
- (STDERR_LEVELS.include?(level) && $stderr.isatty)
44
+ if STDOUT_LEVELS.include?(level) ||
45
+ STDERR_LEVELS.include?(level)
46
46
  Rainbow(message).send(color)
47
47
  else
48
48
  message
@@ -236,7 +236,7 @@ module HTMLProofer
236
236
  end
237
237
 
238
238
  private def load_cache(type)
239
- ivar = instance_variable_get("@#{type}_urls")
239
+ ivar = instance_variable_get(:"@#{type}_urls")
240
240
 
241
241
  existing_urls_count = @cache.size(type)
242
242
  cache_text = pluralize(existing_urls_count, "#{type} link", "#{type} links")
@@ -249,7 +249,7 @@ module HTMLProofer
249
249
 
250
250
  private def format_checks_list(checks)
251
251
  checks.map do |check|
252
- check.sub(/HTMLProofer::Check::/, "")
252
+ check.sub("HTMLProofer::Check::", "")
253
253
  end.sort.join(", ")
254
254
  end
255
255
  end
@@ -120,9 +120,7 @@ module HTMLProofer
120
120
  decoded_href_hash = Addressable::URI.unescape(href_hash)
121
121
  fragment_ids = [href_hash, decoded_href_hash]
122
122
  # https://www.w3.org/TR/html5/single-page.html#scroll-to-fragid
123
- return true if fragment_ids.include?("top")
124
-
125
- nil
123
+ true if fragment_ids.include?("top")
126
124
  end
127
125
 
128
126
  private def hash_exists_in_html?(href_hash, html)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HTMLProofer
4
- VERSION = "5.0.8"
4
+ VERSION = "5.0.9"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html-proofer
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.8
4
+ version: 5.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen Torikian
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-08-06 00:00:00.000000000 Z
11
+ date: 2024-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -230,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
230
230
  - !ruby/object:Gem::Version
231
231
  version: '0'
232
232
  requirements: []
233
- rubygems_version: 3.4.18
233
+ rubygems_version: 3.5.3
234
234
  signing_key:
235
235
  specification_version: 4
236
236
  summary: A set of tests to validate your HTML output. These tests check if your image