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

Investigate HTML-Proofer's external link checking #763

Open
alexwlchan opened this issue Apr 7, 2024 · 1 comment
Open

Investigate HTML-Proofer's external link checking #763

alexwlchan opened this issue Apr 7, 2024 · 1 comment

Comments

@alexwlchan
Copy link
Owner

No description provided.

@alexwlchan
Copy link
Owner Author

Here's an initial draft at a script for it:

# frozen_string_literal: true

# This script checks whether external links are working.
#
# I don't run this in CI because it's slow

require 'html-proofer'

HTMLProofer.check_directory(
  '_site', {
    checks: ['Links'],
    ignore_files: [
      '_site/400/index.html',
      %r{_site/files/.*},
      # This is because of an overly slow regex in HTML-Proofer.
      # See https://github.com/gjtorikian/html-proofer/issues/816
      '_site/2013/google-maps/index.html'
    ],
    #
    # This User-Agent header allows the URl checker to fetch Twitter
    # pages; the default agent gets a 400 error.
    typhoeus: { headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:105.0) Gecko/20100101 Firefox/105.0' } },
    #
    # See https://github.com/gjtorikian/html-proofer?#configuring-caching
    cache: { timeframe: { external: '30d' }, storage_dir: '.htmlproofer' },
    #
    # As of April 2024, I have 334 links which don't use HTTPS.
    # It might be nice to fix them all and/or whitelist them, but
    # they're all external links -- I don't care that much.
    #
    # For now, skip HTTPS checking.
    enforce_https: false
  }
).run

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

1 participant