From d5bd7fb1a63e3ca02688f359c823902e8251419b Mon Sep 17 00:00:00 2001 From: benoit74 Date: Tue, 20 Oct 2026 15:26:41 +0000 Subject: [PATCH 1/3] Resolve relative links against page URLs with consecutive slashes urllib.parse.urljoin collapses empty path segments while merging a relative reference onto the base URL, so a page whose own URL contains `//` had its relative links resolved to the wrong absolute URL (slashes collapsed before normalize() even saw them). Replace it with a custom join that follows RFC 3986 section 5.3 without that deviation, matching how browsers resolve such references. The JS (wombat) side already resolves relative URLs correctly via uri-js's URI.resolve, so only the Python rewriter needed a fix; added a regression test on the JS side to document that. Fix #346 --- CHANGELOG.md | 1 + javascript/test/wombatUrlRewriting.js | 23 ++++++ src/zimscraperlib/rewriting/url_rewriting.py | 84 ++++++++++++++++++-- tests/rewriting/test_url_rewriting.py | 29 +++++++ 4 files changed, 132 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0787983..8a7c209 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Find the language of an HTML page in a `content-language` `` that is not the first `` of the page (#356) - Rewrite the `poster` attribute (e.g. of `