Skip to content

fix: honour preserve_https_for_internal_links for prefetch and <base href> - #2436

Open
workflowsdiy wants to merge 3 commits into
unclecode:developfrom
workflowsdiy:bugfix/prefetch-https-preservation
Open

workflowsdiy wants to merge 3 commits into
unclecode:developfrom
workflowsdiy:bugfix/prefetch-https-preservation

Conversation

@workflowsdiy

Copy link
Copy Markdown

With preserve_https_for_internal_links=True, the same HTTPS page produced different links in prefetch and normal mode, and <base href> handling in normal mode upgraded links on other hosts.

Examples, for page https://example.com/:

  1. <a href="http://example.com/docs">: normal mode gave https://example.com/docs, prefetch gave http://example.com/docs. Prefetch returns before the scraping strategy runs, and quick_extract_links never received the option.
  2. <base href="http://other.com/"> with <a href="chapter">: normal mode gave https://other.com/chapter. The same-host check compared against the <base> host, so a link to another host was rewritten.
  3. <base href="http://EXAMPLE.COM/"> with <a href="chapter">: a case-sensitive host comparison stopped a same-host link being upgraded.

Fix:

  • quick_extract_links accepts preserve_https and original_scheme, and AsyncWebCrawler passes them from the config and the requested scheme.
  • In both quick_extract_links and content_scraping_strategy, links resolve against <base href>, but the same-host check uses the page URL.
  • normalize_url and normalize_url_for_deep_crawl compare hosts case-insensitively.

Tests: tests/test_prefetch_mode.py covers prefetch and normal mode for same-host upgrade, option off, cross-host <base>, mixed-case <base>, and an https-to-http redirect. Existing prefetch, deep-crawl and scraping-strategy tests pass. Six failures in test_normalize_url.py and test_link_extractor.py also occur on develop and are unrelated.

🤖 Generated with Claude Code

workflowsdiy and others added 3 commits October 22, 2026 09:02
…inks

Prefetch returns before the scraping strategy runs, and quick_extract_links
normalized links without the HTTPS-preservation arguments. So with
preserve_https_for_internal_links=True, the same page gave different internal
links in prefetch and in the normal path. Pass the option and the requested
scheme through, as the scraping strategy already does.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
…e href>

The normal scraping path replaced the page URL with <base href> before
normalizing links, so with preserve_https_for_internal_links=True a
<base href="http://other.com/"> on an https page turned its links into
https://other.com/... Resolve against the base, but check same-host against
the page URL, as the prefetch path now does.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
A <base href> spelling the page's host in capitals (http://EXAMPLE.COM/) no
longer counted as same-host, so its links were not upgraded to https.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
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

Successfully merging this pull request may close these issues.

1 participant