From e8ade91f215b086620913e9245b1bfea6ae5a689 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Sun, 16 Aug 2026 06:56:06 +0200 Subject: [PATCH] lib.Uri: Fix path join for empty authority __new_with_path() joins base and path with exactly one '/', assuming a trailing '/' in base is a path separator. That assumption breaks for URIs with empty authority, where scheme_plus_authority ends in '://' (e.g. 'file:///tmp/x'): new_replace_path('/etc/hosts') drops the leading slash of the path and produces 'file://etc/hosts', which parses with hostname 'etc' and path '/hosts' instead of path '/etc/hosts'. Treat a base ending in '://' separately and keep a leading slash in the path, adding one if it is missing. Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.84.2 Signed-off-by: Jan Lindemann --- src/python/jw/pkg/lib/Uri.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/python/jw/pkg/lib/Uri.py b/src/python/jw/pkg/lib/Uri.py index 422ef1d8..51534410 100644 --- a/src/python/jw/pkg/lib/Uri.py +++ b/src/python/jw/pkg/lib/Uri.py @@ -161,6 +161,12 @@ class Uri: ret.__password = None if not path: return ret + if ret.__string.endswith('://'): + # -- Empty authority: the trailing '/' is part of the '://' + # separator, so a leading slash in path must be kept to stay + # an absolute path + ret.__string += path if path.startswith('/') else '/' + path + return ret if ret.__string[-1] == '/': if path[0] == '/': ret.__string += path[1:]