Skip to content

fix(scraper): resolve relative links against the post-redirect URL - #9

Merged
franckferman merged 1 commit into
stablefrom
dev
Jul 4, 2026
Merged

franckferman merged 1 commit into
stablefrom
dev

Conversation

@franckferman

Copy link
Copy Markdown
Owner

Bug: scraping a URL that 301-redirects (e.g. a GitHub Pages project page: /repo -> /repo/) resolved relative links one directory too high, so every file 404'd.

Fix: fetch_links_from_url returns the effective URL (response.geturl()); process_url uses it as the urljoin base.

Reproduced locally with an http.server that redirects /MetaDetective -> /MetaDetective/: before, all files 404; after, the lab files download correctly. 58 unit tests pass (added a regression test).

fetch_links_from_url now returns the effective URL (response.geturl()) and
process_url uses it as the base for urljoin. Without this, scraping a URL that
redirects - e.g. a GitHub Pages project page where '/repo' 301-redirects to
'/repo/' - resolved relative links one directory too high, causing 404s on
every file. Add a regression test.
@franckferman
franckferman merged commit f7d77f1 into stable Jul 4, 2026
3 checks passed
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