html-proofer 3.18.1 → 3.18.6

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: 60d8c8a9a9d38a05b628f3b6a852e27081ee85b7671a41bf51457f4d5f05440c
4
- data.tar.gz: 8fb0e24b312fdae8eb37c98de0d6498035fd20e46dd71456842916d59daf642b
3
+ metadata.gz: e2d6deb85601ff3f5e5df02999f1b55f29231e5658f1d4fa9986c002b3cc0263
4
+ data.tar.gz: e20a007144a866b41b97eb36a964ca1372d693ade77acc69a9c9e706b353c8ef
5
5
  SHA512:
6
- metadata.gz: 93dc24aec3ae4e94a4352751a41237aedf147493364cb8b40de7c25d8b9e2780969f8159d95f176fef539fe0560b3c28ae229432efdccf5dfeb878d7b765841f
7
- data.tar.gz: caefd93da740afefb6f78c1c1e767bfaddeba2f1b7de248ea426790283a1d97785f75b33123c89d488ba36cdd3d850185400c011830a9f4e5eecd45b52ba6a2a
6
+ metadata.gz: c51154450eb20c04c0b7038effb12ab8d258457ea5560421b5a2a0739342504afebb8fd092fe4378838a076636ff2665eb691f513b8b34b49af2e89ffba988c2
7
+ data.tar.gz: fcb7bf492588fabc991caf1f779fca14a7b553d3ce00dbf55ba24aebf3c39f7613af6a408d94c3a3faaeb21dceb8265ece91ca9bf4320aee7d4f3dca133ba4de
@@ -109,8 +109,13 @@ module HTMLProofer
109
109
  additions
110
110
  end
111
111
 
112
+ # TODO: Garbage performance--both the external and internal
113
+ # caches need access to this file. Write a proper versioned
114
+ # schema in the future
112
115
  def write
113
- File.write(cache_file, @cache_log.to_json)
116
+ file = {}
117
+ file = JSON.parse(File.read(cache_file)) if File.exist?(cache_file)
118
+ File.write(cache_file, file.merge(@cache_log).to_json)
114
119
  end
115
120
 
116
121
  def load?
@@ -51,14 +51,16 @@ class LinkCheck < ::HTMLProofer::Check
51
51
  # curl/Typheous inaccurately return 404s for some links. cc https://git.io/vyCFx
52
52
  next if @link.respond_to?(:rel) && @link.rel == 'dns-prefetch'
53
53
 
54
+ unless @link.path?
55
+ add_issue("#{@link.href} is an invalid URL", line: line, content: content)
56
+ next
57
+ end
58
+
54
59
  add_to_external_urls(@link.href || @link.src)
55
60
  next
56
61
  elsif @link.internal?
57
- if @link.exists?
58
- add_to_internal_urls(@link.href, InternalLink.new(@link, @path, line, content))
59
- else
60
- add_issue("internally linking to #{@link.href}, which does not exist", line: line, content: content)
61
- end
62
+ add_to_internal_urls(@link.href, InternalLink.new(@link, @path, line, content))
63
+ add_issue("internally linking to #{@link.href}, which does not exist", line: line, content: content) if !@link.exists? && !@link.hash
62
64
  end
63
65
  end
64
66
 
@@ -72,10 +74,10 @@ class LinkCheck < ::HTMLProofer::Check
72
74
  return false
73
75
  end
74
76
 
75
- # verify the target hash
76
- return handle_hash(link, path, line, content) if link.hash
77
+ return true unless link.hash
77
78
 
78
- true
79
+ # verify the target hash
80
+ handle_hash(link, path, line, content)
79
81
  end
80
82
 
81
83
  def check_schemes(link, line, content)
@@ -24,7 +24,7 @@ module HTMLProofer
24
24
  raise e
25
25
  end
26
26
 
27
- @aria_hidden = defined?(@aria_hidden) && @aria_hidden == 'true' ? true : false
27
+ @aria_hidden = defined?(@aria_hidden) && @aria_hidden == 'true'
28
28
 
29
29
  @data_proofer_ignore = defined?(@data_proofer_ignore)
30
30
 
@@ -74,6 +74,10 @@ module HTMLProofer
74
74
  !parts.nil?
75
75
  end
76
76
 
77
+ def path?
78
+ !parts.host.nil? && !parts.path.nil?
79
+ end
80
+
77
81
  def parts
78
82
  @parts ||= Addressable::URI.parse url
79
83
  rescue URI::Error, Addressable::URI::InvalidURIError
@@ -216,6 +220,8 @@ module HTMLProofer
216
220
  end
217
221
 
218
222
  def ignores_pattern_check(links)
223
+ return false unless links.is_a?(Array)
224
+
219
225
  links.each do |ignore|
220
226
  case ignore
221
227
  when String
@@ -22,7 +22,7 @@ module HTMLProofer
22
22
  allow_hash_href: true,
23
23
  check_external_hash: true,
24
24
  check_html: true,
25
- url_ignore: [/.*/], # Don't try to check if local files exist
25
+ url_ignore: [%r{^/}], # Don't try to check if local files exist
26
26
  validation: { report_eof_tags: true }
27
27
  }
28
28
  end
@@ -63,7 +63,9 @@ module HTMLProofer
63
63
  swap(url, @options[:url_swap])
64
64
  end
65
65
  end
66
- @external_urls = Hash[*@src.map { |s| [s, nil] }.flatten]
66
+ @external_urls = @src.each_with_object({}) do |url, hash|
67
+ hash[url] = nil
68
+ end
67
69
  validate_external_urls
68
70
  end
69
71
 
@@ -123,7 +125,7 @@ module HTMLProofer
123
125
  end
124
126
 
125
127
  external_urls = check.external_urls
126
- external_urls = Hash[check.external_urls.map { |url, file| [swap(url, @options[:url_swap]), file] }] if @options[:url_swap]
128
+ external_urls = check.external_urls.map { |url, file| [swap(url, @options[:url_swap]), file] }.to_h if @options[:url_swap]
127
129
  result[:external_urls].merge!(external_urls)
128
130
  result[:failures].concat(check.issues)
129
131
  end
@@ -157,11 +159,12 @@ module HTMLProofer
157
159
  @cache.write
158
160
  else
159
161
  @internal_urls.values.flatten.each do |internal_url|
160
- @internal_link_checks.check_internal_link(internal_url.link, internal_url.path, internal_url.line, internal_url.content)
162
+ result = @internal_link_checks.check_internal_link(internal_url.link, internal_url.path, internal_url.line, internal_url.content)
163
+ next if result
164
+
165
+ @failures.concat(@internal_link_checks.issues) unless @internal_link_checks.issues.length.zero?
161
166
  end
162
167
  end
163
-
164
- @failures.concat(@internal_link_checks.issues) unless @internal_urls.length.zero?
165
168
  end
166
169
 
167
170
  def files
@@ -85,7 +85,7 @@ module HTMLProofer
85
85
  # for HEAD. If we've decided to check for hashes, we must do a GET--HEAD is
86
86
  # not available as an option.
87
87
  def external_link_checker(external_urls)
88
- external_urls = Hash[external_urls.sort]
88
+ external_urls = external_urls.sort.to_h
89
89
 
90
90
  count = external_urls.length
91
91
  check_text = pluralize(count, 'external link', 'external links')
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HTMLProofer
4
- VERSION = '3.18.1'
4
+ VERSION = '3.18.6'
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: 3.18.1
4
+ version: 3.18.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen Torikian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-16 00:00:00.000000000 Z
11
+ date: 2021-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -285,9 +285,12 @@ require_paths:
285
285
  - lib
286
286
  required_ruby_version: !ruby/object:Gem::Requirement
287
287
  requirements:
288
- - - "~>"
288
+ - - ">="
289
+ - !ruby/object:Gem::Version
290
+ version: 2.4.10
291
+ - - "<"
289
292
  - !ruby/object:Gem::Version
290
- version: '2.4'
293
+ version: '4.0'
291
294
  required_rubygems_version: !ruby/object:Gem::Requirement
292
295
  requirements:
293
296
  - - ">="