From 59ecb8f8d2ae9db85af1c8c400f305ccc09c4cb5 Mon Sep 17 00:00:00 2001 From: anshuman83-40 <292907463+anshuman83-40@users.noreply.github.com> Date: Thu, 15 Oct 2026 22:10:05 +0530 Subject: [PATCH] Do not collapse consecutive slashes when normalizing URLs a//b and a/b are different URLs which may serve different content, but URL normalization rewrote any run of slashes in the path or querystring as a single one. Keep them as they are, in both the Python normalization and the JS (wombat) URL rewriting, which must produce the same ZIM paths. get_document_uri computed the relative link with PurePosixPath, which collapsed the slashes again; compute it segment by segment instead, keeping empty segments, and prefix it with ./ when it would otherwise start with / (making the link absolute or scheme-relative). Fix #340 --- CHANGELOG.md | 1 + javascript/src/wombatSetup.js | 10 +- javascript/test/wombatUrlRewriting.js | 23 ++- src/zimscraperlib/rewriting/url_rewriting.py | 60 +++++--- tests/rewriting/test_url_rewriting.py | 152 ++++++++++++++++++- 5 files changed, 211 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1de7b951..e1f874c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Keep a rewritten `