Resolve relative outlinks against <base href> in JSoupParserBolt#2011
Merged
Conversation
Relative links were resolved against the document URL, ignoring any <base href> element. On a page served from a sub-path with a base pointing at the domain root this doubled the path segment. Resolve against jsoupDoc.baseUri() instead, which honours <base> and falls back to the document URL when absent.
rzo1
approved these changes
Jul 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
JSoupParserBoltresolved relative outlinks against the document URL, ignoring any<base href>element in the page. For a page served from a sub-path whose<base>points at the domain root, this doubled the path segment.Example — page
https://host/fr/rayons/actualites-reportages/216943with<base href="https://host/">and a linkhref="fr/rayons/stockage-archivage-de-donnees/218725":https://host/fr/rayons/stockage-archivage-de-donnees/218725https://host/fr/rayons/actualites-reportages/fr/rayons/stockage-archivage-de-donnees/218725Fix
Resolve relative links against
jsoupDoc.baseUri()instead of the raw document URL. jsoup updatesbaseUri()to the<base href>value when the element is present, matching browser behaviour, and falls back to the document URL otherwise. This keeps the existing fast resolution path (no per-linkabs:hrefobject building).Test
Added
testBaseHrefOutlinkResolutionreproducing the doubled-path case. It fails without the fix (producing the doubled URL) and passes with it. FullJSoupParserBoltTestclass: 12/12 passing.