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

Passing RegExp to --ignore-url broken after v4.2.0 release #745

Closed
nwhetsell opened this issue Jul 29, 2022 · 6 comments
Closed

Passing RegExp to --ignore-url broken after v4.2.0 release #745

nwhetsell opened this issue Jul 29, 2022 · 6 comments

Comments

@nwhetsell
Copy link
Contributor

Passing a RegExp to --ignore-url, like—

htmlproofer webpage.html --ignore-urls '/^images\//'

—appears to be broken in v4.3.1 (URLs that start with images/ are no longer ignored). This worked in v4.2.0.

@gjtorikian
Copy link
Owner

Hm. Could you show build output or a file where this is the case? I just tried the following and it passed as expected:

htmlproofer spec/html-proofer/fixtures/links/broken_link_external.html --ignore-urls '/^https/'

@nwhetsell
Copy link
Contributor Author

This is a little more involved than I thought; I have to also use --allow-missing-href:

  1. Create a minimal HTML file:

    cat <<EOS > test.html
    <!DOCTYPE html>
    <html lang="en">
    <head>
      <title>HTMLProofer issue #745</title>
    </head>
    <body>
      <img src="images/nonexistent.png" alt="Nonexistent image">
    </body>
    </html>
    EOS
  2. Install and run HTMLProofer v4.2.0 (your path to htmlproofer may be different):

    gem install --version 4.2.0 html-proofer
    /usr/local/lib/ruby/gems/3.1.0/gems/html-proofer-4.2.0/bin/htmlproofer test.html --allow-missing-href --ignore-urls '/^images\//'

    HTMLProofer ignores the nonexistent image, as expected:

    Running 3 checks (Images, Scripts, Links) in test.html on *.html files...
    
    
    Ran on 1 file!
    
    
    HTML-Proofer finished successfully.
    
  3. Install and run HTMLProofer v4.3.1:

    gem install --version 4.3.1 html-proofer
    /usr/local/lib/ruby/gems/3.1.0/gems/html-proofer-4.3.1/bin/htmlproofer test.html --allow-missing-href --ignore-urls '/^images\//'

    HTMLProofer unexpectedly doesn’t ignore the nonexistent image:

    Running 3 checks (Scripts, Links, Images) in test.html on *.html files...
    
    
    Checking 0 external links
    Checking 0 internal links
    Ran on 1 file!
    
    
    For the Images check, the following failures were found:
    
    * At test.html:7:
    
      internal image images/nonexistent.png does not exist
    
    
    HTML-Proofer found 1 failure!
    

@riccardoporreca
Copy link
Collaborator

@nwhetsell, you should use --allow-missing-href=true to make sure the CLI parser does not mess up with options, see #735 (comment) and the discussion in #743 (which also highlights how this was impacted by 4.3.0)

@nwhetsell
Copy link
Contributor Author

Will do, thanks!

@gjtorikian
Copy link
Owner

Bleh, so sorry this is another CLI arg issue.

@nwhetsell
Copy link
Contributor Author

@gjtorikian No worries, thanks for your help and for all the work you do on HTMLProofer!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants