html-proofer 3.17.2 → 3.18.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/html-proofer.rb +2 -0
- data/lib/html-proofer/check.rb +2 -2
- data/lib/html-proofer/check/favicon.rb +1 -1
- data/lib/html-proofer/check/links.rb +9 -9
- data/lib/html-proofer/middleware.rb +1 -1
- data/lib/html-proofer/runner.rb +10 -5
- data/lib/html-proofer/url_validator.rb +1 -1
- data/lib/html-proofer/version.rb +1 -1
- metadata +3 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 852efb42767ef8589aa2f469f06c807ab287d78da04043e5a57e4d4a7f8bf6dd
|
4
|
+
data.tar.gz: 065406c8f1a7978d025224dc4ef53137e698eaeec8f097c1375620c8d6e0c5ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5aabdd3e5087dd1282b4428b7105e62216b22510c1a73a9f80f1e6b2ba18906217c7aaa974b245644de2b325bef8fd3e05c61c528302fb59ce5a353da0c1d04
|
7
|
+
data.tar.gz: 7155e2eed2e31173ad7e8efe4d7ce31b2cf18fa403b560f03428e3ef8ff8f9c60654f9e1ee6a4470ff65f609fdaeeb107e0236c85610212e90b7a9535a650522
|
data/lib/html-proofer.rb
CHANGED
data/lib/html-proofer/check.rb
CHANGED
@@ -26,8 +26,8 @@ module HTMLProofer
|
|
26
26
|
raise NotImplementedError, 'HTMLProofer::Check subclasses must implement #run'
|
27
27
|
end
|
28
28
|
|
29
|
-
def add_issue(desc, line: nil, status: -1, content: nil)
|
30
|
-
@issues << Issue.new(@path, desc, line: line, status: status, content: content)
|
29
|
+
def add_issue(desc, line: nil, path: nil, status: -1, content: nil)
|
30
|
+
@issues << Issue.new(path || @path, desc, line: line, status: status, content: content)
|
31
31
|
false
|
32
32
|
end
|
33
33
|
|
@@ -45,7 +45,7 @@ class LinkCheck < ::HTMLProofer::Check
|
|
45
45
|
# intentionally here because we still want valid? & missing_href? to execute
|
46
46
|
next if @link.non_http_remote?
|
47
47
|
|
48
|
-
if !@link.internal? && @link.remote?
|
48
|
+
if !@link.href&.start_with?('#') && !@link.internal? && @link.remote?
|
49
49
|
check_sri(line, content) if @link.check_sri? && node.name == 'link'
|
50
50
|
# we need to skip these for now; although the domain main be valid,
|
51
51
|
# curl/Typheous inaccurately return 404s for some links. cc https://git.io/vyCFx
|
@@ -54,7 +54,7 @@ class LinkCheck < ::HTMLProofer::Check
|
|
54
54
|
add_to_external_urls(@link.href || @link.src)
|
55
55
|
next
|
56
56
|
elsif @link.internal?
|
57
|
-
if @link.exists?
|
57
|
+
if @link.exists? || @link.hash
|
58
58
|
add_to_internal_urls(@link.href, InternalLink.new(@link, @path, line, content))
|
59
59
|
else
|
60
60
|
add_issue("internally linking to #{@link.href}, which does not exist", line: line, content: content)
|
@@ -65,17 +65,17 @@ class LinkCheck < ::HTMLProofer::Check
|
|
65
65
|
external_urls
|
66
66
|
end
|
67
67
|
|
68
|
-
def check_internal_link(link, line, content)
|
68
|
+
def check_internal_link(link, path, line, content)
|
69
69
|
# does the local directory have a trailing slash?
|
70
70
|
if link.unslashed_directory?(link.absolute_path)
|
71
|
-
add_issue("internally linking to a directory #{link.absolute_path} without trailing slash", line: line, content: content)
|
71
|
+
add_issue("internally linking to a directory #{link.absolute_path} without trailing slash", path: path, line: line, content: content)
|
72
72
|
return false
|
73
73
|
end
|
74
74
|
|
75
|
-
|
76
|
-
return handle_hash(link, line, content) if link.hash
|
75
|
+
return true unless link.hash
|
77
76
|
|
78
|
-
|
77
|
+
# verify the target hash
|
78
|
+
handle_hash(link, path, line, content)
|
79
79
|
end
|
80
80
|
|
81
81
|
def check_schemes(link, line, content)
|
@@ -103,9 +103,9 @@ class LinkCheck < ::HTMLProofer::Check
|
|
103
103
|
add_issue("#{link.href} contains no phone number", line: line, content: content) if link.path.empty?
|
104
104
|
end
|
105
105
|
|
106
|
-
def handle_hash(link, line, content)
|
106
|
+
def handle_hash(link, path, line, content)
|
107
107
|
if link.internal? && !hash_exists?(link.html, link.hash) # rubocop:disable Style/GuardClause
|
108
|
-
return add_issue("linking to internal hash ##{link.hash} that does not exist", line: line, content: content)
|
108
|
+
return add_issue("linking to internal hash ##{link.hash} that does not exist", path: path, line: line, content: content)
|
109
109
|
elsif link.external?
|
110
110
|
return external_link_check(link, line, content)
|
111
111
|
end
|
data/lib/html-proofer/runner.rb
CHANGED
@@ -147,18 +147,22 @@ module HTMLProofer
|
|
147
147
|
urls_to_check = load_internal_cache
|
148
148
|
|
149
149
|
urls_to_check.each_pair do |url, internal_urls|
|
150
|
-
|
150
|
+
# pulled from cache
|
151
|
+
internal_urls = @internal_urls[url] unless internal_urls.first.is_a?(LinkCheck::InternalLink)
|
152
|
+
|
153
|
+
result = @internal_link_checks.check_internal_link(internal_urls.first.link, internal_urls.first.path, internal_urls.first.line, internal_urls.first.content)
|
151
154
|
code = result ? 200 : 404
|
152
155
|
@cache.add(url, @internal_urls_to_paths[url].sort, code, '') # TODO: blank msg for now
|
153
156
|
end
|
154
157
|
@cache.write
|
155
158
|
else
|
156
159
|
@internal_urls.values.flatten.each do |internal_url|
|
157
|
-
@internal_link_checks.check_internal_link(internal_url.link, internal_url.line, internal_url.content)
|
160
|
+
result = @internal_link_checks.check_internal_link(internal_url.link, internal_url.path, internal_url.line, internal_url.content)
|
161
|
+
next if result
|
162
|
+
|
163
|
+
@failures.concat(@internal_link_checks.issues) unless @internal_link_checks.issues.length.zero?
|
158
164
|
end
|
159
165
|
end
|
160
|
-
|
161
|
-
@failures.concat(@internal_link_checks.issues) unless @internal_urls.length.zero?
|
162
166
|
end
|
163
167
|
|
164
168
|
def files
|
@@ -211,7 +215,8 @@ module HTMLProofer
|
|
211
215
|
sorted_failures.sort_and_report
|
212
216
|
count = @failures.length
|
213
217
|
failure_text = pluralize(count, 'failure', 'failures')
|
214
|
-
|
218
|
+
@logger.log :fatal, "\nHTML-Proofer found #{failure_text}!"
|
219
|
+
exit 1
|
215
220
|
end
|
216
221
|
|
217
222
|
# Set before_request callback.
|
@@ -120,7 +120,7 @@ module HTMLProofer
|
|
120
120
|
def clean_url(href)
|
121
121
|
# catch any obvious issues, like strings in port numbers
|
122
122
|
parsed = Addressable::URI.parse(href)
|
123
|
-
if href =~ /^([!#{
|
123
|
+
if href =~ /^([!#{Regexp.last_match(0)}-;=?-\[\]_a-z~]|%[0-9a-fA-F]{2})+$/
|
124
124
|
href
|
125
125
|
else
|
126
126
|
parsed.normalize
|
data/lib/html-proofer/version.rb
CHANGED
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.
|
4
|
+
version: 3.18.2
|
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-
|
11
|
+
date: 2020-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -122,20 +122,6 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: codecov
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - ">="
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '0'
|
139
125
|
- !ruby/object:Gem::Dependency
|
140
126
|
name: pry-byebug
|
141
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -308,7 +294,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
308
294
|
- !ruby/object:Gem::Version
|
309
295
|
version: '0'
|
310
296
|
requirements: []
|
311
|
-
rubygems_version: 3.1.
|
297
|
+
rubygems_version: 3.1.4
|
312
298
|
signing_key:
|
313
299
|
specification_version: 4
|
314
300
|
summary: A set of tests to validate your HTML output. These tests check if your image
|