Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cleaning relative links cache key #793

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/html_proofer/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,10 @@ def retrieve_urls(urls_detected, type)
# if there are no urls, bail
return {} if urls_detected.empty?

urls_detected = urls_detected.transform_keys do |url|
cleaned_url(url)
if type == :external
urls_detected = urls_detected.transform_keys do |url|
cleaned_url(url)
end
end
gjtorikian marked this conversation as resolved.
Show resolved Hide resolved
Comment on lines +96 to 100
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I think we may want to only avoid escape_unescape for the external links, since the other part of cleaned_url that handles trailing "/", "#", "?" would still be relevant for internal links. Any input on this @gjtorikian?
If we keep part of cleaned_url for internal links, we should probably also include it to add_internal for consistency, similar to what is done for add_external


urls_to_check = detect_url_changes(urls_detected, type)
Expand Down
2 changes: 1 addition & 1 deletion lib/html_proofer/url_validator/external.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def check_hash_in_2xx_response(href, url, response, filenames)

# attempt to verify PDF hash ref; see #787 for more details
# FIXME: this is re-reading the PDF response
if content_type && /pdf/.match?(content_type[1])
if content_type && content_type[1].include?("pdf")
io = URI.parse(url.to_s).open
reader = PDF::Reader.new(io)

Expand Down
2 changes: 1 addition & 1 deletion lib/html_proofer/xpath_functions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module HTMLProofer
# https://stackoverflow.com/a/8812293
class XpathFunctions
def case_sensitive_equals(node_set, str_to_match)
node_set.find_all { |node| node.to_s.== str_to_match.to_s }
node_set.find_all { |node| node.to_s == str_to_match.to_s }
end
end
end
2 changes: 1 addition & 1 deletion spec/html-proofer/command_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
end

it "navigates above itself in a subdirectory" do
real_link = File.join(FIXTURES_DIR, "links", "root_folder/documentation-from-my-project/")
real_link = File.join(FIXTURES_DIR, "links", "root_folder/admin/")
output = make_bin("--root-dir #{File.join(FIXTURES_DIR, "links", "root_folder/")} #{real_link}")
expect(output).to(match("successfully"))
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<a href="../admin/root_link.html"> </a>
Loading