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

remove proprietary pdf #790

Merged
merged 2 commits into from
Jan 26, 2023
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
10 changes: 10 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,13 @@ gemspec
gem "ruby-lsp", "~> 0.3.2", group: :development

gem "github_changelog_generator", "~> 1.16"

gem "awesome_print"

gem "debug" if "#{RbConfig::CONFIG["MAJOR"]}.#{RbConfig::CONFIG["MINOR"]}".to_f >= 3.1
gem "rake"
gem "redcarpet"

gem "rubocop"
gem "rubocop-rspec"
gem "rubocop-standard"
7 changes: 0 additions & 7 deletions html-proofer.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,7 @@ Gem::Specification.new do |spec|
spec.add_dependency("yell", "~> 2.0")
spec.add_dependency("zeitwerk", "~> 2.5")

spec.add_development_dependency("awesome_print")
spec.add_development_dependency("debug") if "#{RbConfig::CONFIG["MAJOR"]}.#{RbConfig::CONFIG["MINOR"]}".to_f >= 3.1
spec.add_development_dependency("rake")
spec.add_development_dependency("redcarpet")
spec.add_development_dependency("rspec", "~> 3.1")
spec.add_development_dependency("rubocop")
spec.add_development_dependency("rubocop-rspec")
spec.add_development_dependency("rubocop-standard")
spec.add_development_dependency("timecop", "~> 0.8")
spec.add_development_dependency("vcr", "~> 2.9")
end
2 changes: 1 addition & 1 deletion lib/html_proofer/attribute/url.rb
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def param_link?
url.start_with?("?")
end

def sans_hash
def without_hash
@url.to_s.sub(/##{hash}/, "")
end

Expand Down
4 changes: 2 additions & 2 deletions lib/html_proofer/url_validator/external.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def check_hash_in_2xx_response(href, url, response, filenames)
page = Regexp.last_match[1].to_i

unless pages[page - 1]
msg = "External link #{href} failed: #{url.sans_hash} exists, but the hash '#{hash}' does not"
msg = "External link #{href} failed: #{url.without_hash} exists, but the hash '#{hash}' does not"
add_failure(filenames, msg, response.code)
@cache.add_external(href, filenames, response.code, msg, false)
end
Expand All @@ -158,7 +158,7 @@ def check_hash_in_2xx_response(href, url, response, filenames)

return unless body_doc.xpath(xpath.join("|")).empty?

msg = "External link #{href} failed: #{url.sans_hash} exists, but the hash '#{hash}' does not"
msg = "External link #{href} failed: #{url.without_hash} exists, but the hash '#{hash}' does not"
add_failure(filenames, msg, response.code)
@cache.add_external(href, filenames, response.code, msg, false)
true
Expand Down
5 changes: 4 additions & 1 deletion spec/html-proofer/fixtures/links/pdf_w_hash.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
<!DOCTYPE html>
<a href='https://checkoway.net/teaching/cs210/2021-fall/slides/Lec19%20ClocksandTiming.pdf#page=25'>X</a>
<a
href="https://upload.wikimedia.org/wikipedia/commons/0/07/Open_Content_-_A_Practical_Guide_to_Using_Creative_Commons_Licences.pdf#page=2"
>X</a
>
5 changes: 4 additions & 1 deletion spec/html-proofer/fixtures/links/pdf_w_hash_broken.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
<!DOCTYPE html>
<a href='https://checkoway.net/teaching/cs210/2021-fall/slides/Lec19%20ClocksandTiming.pdf#page=2111115'>X</a>
<a
href="https://upload.wikimedia.org/wikipedia/commons/0/07/Open_Content_-_A_Practical_Guide_to_Using_Creative_Commons_Licences.pdf#page=2111115"
>X</a
>

Large diffs are not rendered by default.

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion spec/html-proofer/links_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -760,11 +760,12 @@
it "tries reading PDFs with hashes" do
file = File.join(FIXTURES_DIR, "links", "pdf_w_hash.html")
proofer = run_proofer(file, :file)

expect(proofer.failed_checks.count).to(eq(0))

file = File.join(FIXTURES_DIR, "links", "pdf_w_hash_broken.html")
proofer = run_proofer(file, :file)
expect(proofer.failed_checks.count).to(eq(1))
expect(proofer.failed_checks.first.description).to(match(/ClocksandTiming.pdf exists, but the hash 'page=2111115' does not/))
expect(proofer.failed_checks.first.description).to(match(/.pdf exists, but the hash 'page=2111115' does not/))
end
end