Skip to content

Resolve relative links in fetched pages against the page URL - #5

Open
sharmis-tp wants to merge 1 commit into
cppalliance:masterfrom
sharmis-tp:absolute-links
Open

sharmis-tp wants to merge 1 commit into
cppalliance:masterfrom
sharmis-tp:absolute-links

Conversation

@sharmis-tp

Copy link
Copy Markdown
Collaborator

web/fetch returned links and image sources as the page wrote them, so /learn came back as [Learn](/learn), which a model cannot fetch. readabilityrs takes the base URL but its fix_relative_urls_in_html ignores it, and htmd never resolves links.

Before either renderer runs, every relative a href and img src is now resolved against the page's final URL, or its first <base href> when that is http or https. Fragments, absolute URLs, and references that resolve to another scheme stay as written. The walk is iterative, so deep nesting cannot overflow the stack.

html5ever and markup5ever_rcdom are the crates htmd already builds on, at its versions, so the lockfile gains no crate.

Tested: six new tests in response.rs (readability mode, raw mode, <base>, a non-http <base>, links left as written, no base URL), and the release library fetching https://www.rust-lang.org/ returns no relative links.

@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 494017c9-d75c-4902-9f01-cfc484393f6a
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@sharmis-tp sharmis-tp self-assigned this Nov 24, 2026
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