html-proofer 3.17.0 → 3.17.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: 9b5a47189e872130e01a2080e6e8ddb1f7f22520098deaf941960194d2338b2b
4
- data.tar.gz: 3543c42860956427e8c828861f76e1c5cd984d79054c091c6e5f97e0352b3137
3
+ metadata.gz: f8be1f60d1495959b468c2cfad3a4d659a5817b934bb2011906540d296e2a062
4
+ data.tar.gz: 39ecb6a6899913c4745289443ff77cf1483d3578689fc616099bb00df90a4f16
5
5
  SHA512:
6
- metadata.gz: 1defd1fb2ee651015231b0ed4d1407ed56e25a907e0602ee9e175b23f3b88938e020f438d2171ceea8d52bc58984901543c97184a3da13c9b08cdaf62200a4aa
7
- data.tar.gz: 97eb6120db724822830398a85f14faa4415638e965d21aef0703991e7a14d335f32df65d72bb877be6f0706f24154deea3f08a6bbeb2cdf5d7c392d03ce2af23
6
+ metadata.gz: ce1749adb1022b2a3245396c28b990d4de6bfe368fb5944cddf81b48822f54dff8c744b847e65bcd4cb040f2e7f63a1cbdcccebda943380ab767ecbd96161c8a
7
+ data.tar.gz: 0ffc3e5095dbf40272113991b521a0909408a40715efb2119bfd8f4a310b62b6884fe2566beb198e873f781d6d0ebefed06a966a91a4772309c53835c66ce483
@@ -50,7 +50,7 @@ Mercenary.program(:htmlproofer) do |p|
50
50
  p.option 'typhoeus_config', '--typhoeus-config CONFIG', String, 'JSON-formatted string of Typhoeus config. Will override the html-proofer defaults.'
51
51
  p.option 'url_ignore', '--url-ignore link1,[link2,...]', Array, 'A comma-separated list of Strings or RegExps containing URLs that are safe to ignore. It affects all HTML attributes. Note that non-HTTP(S) URIs are always ignored'
52
52
  p.option 'url_swap', '--url-swap re:string,[re:string,...]', Array, 'A comma-separated list containing key-value pairs of `RegExp => String`. It transforms URLs that match `RegExp` into `String` via `gsub`. The escape sequences `\\:` should be used to produce literal `:`s.'
53
- p.option 'root_dir', '--root-folder PATH', String, 'The absolute path to the directory serving your html-files. Used when running html-proofer on a file, rather than a directory.'
53
+ p.option 'root_dir', '--root-dir PATH', String, 'The absolute path to the directory serving your html-files.'
54
54
 
55
55
  p.action do |args, opts|
56
56
  args = ['.'] if args.empty?
@@ -169,6 +169,10 @@ module HTMLProofer
169
169
  url.start_with?('?')
170
170
  end
171
171
 
172
+ def absolute_path?(path)
173
+ path.start_with?('/')
174
+ end
175
+
172
176
  def file_path
173
177
  return if path.nil? || path.empty?
174
178
 
@@ -176,22 +180,16 @@ module HTMLProofer
176
180
 
177
181
  path_dot_ext = path + @check.options[:extension] if @check.options[:assume_extension]
178
182
 
179
- if %r{^/}.match?(path) # path relative to root
180
- if File.directory?(@check.src)
181
- base = @check.src
182
- else
183
- root_dir = @check.options[:root_dir]
184
- base = root_dir || File.dirname(@check.src)
185
- end
186
- elsif File.exist?(File.expand_path(path, @check.src)) || File.exist?(File.expand_path(path_dot_ext, @check.src)) # relative links, path is a file
187
- base = File.dirname @check.path
188
- elsif File.exist?(File.join(File.dirname(@check.path), path)) || File.exist?(File.join(File.dirname(@check.path), path_dot_ext)) # rubocop:disable Lint/DuplicateBranch; relative links in nested dir, path is a file
189
- base = File.dirname @check.path
190
- else # relative link, path is a directory
191
- base = @check.path
192
- end
193
-
194
- file = File.join base, path
183
+ base = if absolute_path?(path) # path relative to root
184
+ @check.options[:root_dir] || File.dirname(@check.src)
185
+ elsif File.exist?(File.expand_path(path, @check.src)) || File.exist?(File.expand_path(path_dot_ext, @check.src)) # relative links, path is a file
186
+ File.dirname(@check.path)
187
+ elsif File.exist?(File.join(File.dirname(@check.path), path)) || File.exist?(File.join(File.dirname(@check.path), path_dot_ext)) # rubocop:disable Lint/DuplicateBranch; relative links in nested dir, path is a file
188
+ File.dirname(@check.path)
189
+ else # relative link, path is a directory
190
+ @check.path
191
+ end
192
+ file = File.join(base, path)
195
193
  if @check.options[:assume_extension] && File.file?("#{file}#{@check.options[:extension]}")
196
194
  file = "#{file}#{@check.options[:extension]}"
197
195
  elsif File.directory?(file) && !unslashed_directory?(file) # implicit index support
@@ -203,14 +201,15 @@ module HTMLProofer
203
201
 
204
202
  # checks if a file exists relative to the current pwd
205
203
  def exists?
206
- return @checked_paths[absolute_path] if @checked_paths.key? absolute_path
204
+ return @checked_paths[absolute_path] if @checked_paths.key?(absolute_path)
207
205
 
208
- @checked_paths[absolute_path] = File.exist? absolute_path
206
+ @checked_paths[absolute_path] = File.exist?(absolute_path)
209
207
  end
210
208
 
211
209
  def absolute_path
212
210
  path = file_path || @check.path
213
- File.expand_path path, Dir.pwd
211
+
212
+ File.expand_path(path, Dir.pwd)
214
213
  end
215
214
 
216
215
  def ignores_pattern_check(links)
@@ -226,7 +226,7 @@ module HTMLProofer
226
226
  # @return [ Array<Block> ] All before_request blocks.
227
227
  def before_request(&block)
228
228
  @before_request ||= []
229
- @before_request << block if block_given?
229
+ @before_request << block if block
230
230
  @before_request
231
231
  end
232
232
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HTMLProofer
4
- VERSION = '3.17.0'
4
+ VERSION = '3.17.1'
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.17.0
4
+ version: 3.17.1
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-14 00:00:00.000000000 Z
11
+ date: 2020-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable