Skip to content

Commit 15bf0da

Browse files
committed
explain myself
1 parent 6636e5e commit 15bf0da

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

lib/html-proofer/element.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,18 +181,16 @@ def file_path
181181
path_dot_ext = path + @check.options[:extension] if @check.options[:assume_extension]
182182

183183
base = if absolute_path?(path) # path relative to root
184-
if File.directory?(@check.src)
185-
@check.options[:root_dir] || @check.src
186-
else
187-
@check.options[:root_dir] || File.dirname(@check.src)
188-
end
184+
# either overwrite with root_dir; or, if source is directory, use that; or, just get the current file's dirname
185+
@check.options[:root_dir] || (File.directory?(@check.src) ? @check.src : File.dirname(@check.src))
189186
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
190187
File.dirname(@check.path)
191188
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
192189
File.dirname(@check.path)
193190
else # relative link, path is a directory
194191
@check.path
195192
end
193+
196194
file = File.join(base, path)
197195

198196
if @check.options[:assume_extension] && File.file?("#{file}#{@check.options[:extension]}")

0 commit comments

Comments
 (0)