Scheduled broken-link and redirect checks that tell you the moment a link breaks — linkbruno.com
You moved the site to HTTPS years ago. In the footer, in a decade of blog posts, in a CSS url(), in an email template, there is still an http:// link. The browser may upgrade it. A link checker may follow a 301 to the HTTPS URL and report "fine". A CI policy has to decide: treat the leftover scheme as a failure, silently rewrite it to https:// and check that, or only complain when the upgraded request fails.
The argument is whether the scheme itself is a bug, or only a failed upgrade is.
Let's argue about it.
The case for failing the build on leftover http://
The document is wrong. The href that shipped is not the href you meant. Browsers with HSTS, or with an "upgrade mixed content" behaviour, may hide it. curl, an email client, an RSS reader, a native app, and a bot that does not upgrade will still request HTTP. Some will get a 301; some will get a timeout, a captive portal, or a warning. The link you published should be the link you want used.
Auto-upgrade hides destinations that have no HTTPS. http://legacy.example.org/spec may 200. https://legacy.example.org/spec may be a different host, a self-signed cert, or a reset. If the checker rewrites the scheme and the HTTPS URL is a parked page that happens to 200, you have just "fixed" a link by pointing at the wrong document. If HTTPS is dead and the checker follows a redirect back to HTTP, you may not even fail the build.
Mixed content is still a real class of bug. An http:// image, script or stylesheet on an HTTPS page is blocked in the browser. A policy that auto-upgrades in the checker can hide an asset that exists on HTTPS today and loses its certificate tomorrow.
A failing build is a queue of work you can count. Auto-upgrade, plus a warning nobody reads, leaves the corpus as it is. Five years later you still have 400 HTTP links, and you still do not know which of them were checked on the scheme a client will use.
The case for auto-upgrading (or warning) instead of failing
Most leftover http:// links are leftovers, not decisions. They were written when the destination was HTTP-only, and the destination has been on HTTPS with a redirect for years. Failing CI on every one of them, on a blog with 800 posts, is a week of busywork that does not change what the user receives. The 301 already does the job.
A hard fail fights with third parties you do not control. Some vendors, internal tools, and ancient faculty pages still do not serve HTTPS, or serve it so badly that the HTTP URL is the one that works. You can special-case them, and then the special-case list becomes the product.
Docs and examples use http:// on purpose. http://localhost:3000, http://example.com in an RFC-style snippet, a tutorial about redirecting HTTP to HTTPS, a code sample that shows a Location header. A naive "fail on http:// anywhere in the repo" rule will fail those builds.
Rewrites at check time are how a lot of good tools already work. Follow redirects, ignore trailing slashes, treat www as optional. Upgrading the scheme before the request is the same kind of normalisation. Report the 404 if the effective URL is dead; do not fail a green 301.
Where I've landed
I want the scheme in the source to be correct for anything we own, and the build to be loud about mixed content, without turning every historical HTTP href into a red build on Monday.
-
Fail the build on
http://assets that will be loaded by an HTTPS page. Scripts, stylesheets, images, fonts, XHR/fetch endpoints in first-party HTML. That is mixed content. Do not auto-upgrade those as a way of making CI green; change the source, or they will break in the browser the moment the upgrade path does. -
For ordinary navigation links to our hosts, fail (or automatically rewrite the source) rather than just the request. If we serve HTTPS, our own hrefs should say so. A one-time rewrite PR is better than a checker that pretends the file already says
https://. After that, a leftoverhttp://example.com/...in a new commit is a regression and should fail. - For navigation links to other hosts, check both, and fail only when there is no working path. Try HTTPS first, then the original HTTP if HTTPS does not work. If HTTPS works, record a warning with a count; do not fail a 400-post archive over it. If neither works, that is a broken link, scheme aside. If only HTTP works, leave it and list it, so a human can decide.
-
Exempt obvious special cases by rule, not by gut.
localhost,127.0.0.1,.local, example domains in test fixtures, andhttp://inside fenced code blocks. If a policy cannot tell a code sample from a footer link, it is not ready to fail the build.
A link checker that quietly upgrades the scheme can give you a green report for a URL your email client or a non-browser tool will still request as HTTP. linkbruno.com checks the URL as it was published, on a schedule, so a leftover
http://that no longer redirects — or never did — shows up as a real failure.
The parts I'm still unsure about
-
Email and PDFs. Clients are worse at upgrading than browsers, and you often cannot rewrite the artefact once it is sent or downloaded. I would fail the build on
http://in anything that leaves the site as a message or a file, even if I only warn on the blog archive. - HSTS preload. If the destination is on the preload list, browsers will never make the HTTP request. That is a strong argument for "warning only" — for browsers. It is no argument at all for curl, or for a mail app.
-
Automatic rewrite PRs. A bot that opens a pull request changing
http://tohttps://where the upgraded URL returns 200 is a reasonable end state for first-party links. I have also seen those bots flip a URL to a different document behind a catch-all certificate. A 200 is not enough; the checker should insist on a sensible redirect or an identical host.
If you can only pick one policy this week, fail on mixed-content assets and on HTTP links to your own host. That is the set you can fix, and the set that will bite you in a browser.
Related reading
- How to find URLs that work in the browser (service worker or cached redirect) but 404 on a cold request
- How to check links with lychee in GitHub Actions (config, caching, and the false positives to exclude)
- Should your link checker ignore URLs that differ only by UTM and tracking parameters? Let's argue about it
- Should internal links be relative or absolute? Let's argue about it
What does your CI do with leftover http:// links today — fail, auto-upgrade, or ignore the scheme? Which false positive would you not be willing to look at every day?
Top comments (0)