lib.ExecApp: Add class #76

Closed
Jan Lindemann wants to merge 17 commits from jan/feature/20260822-lib-execapp-add-class into master AGit
Showing only changes of commit 104c6d9040 - Show all commits

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 <jan@janware.com>
Jan Lindemann 2026-08-16 06:56:06 +02:00
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61

View file

@ -156,6 +156,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:]