lib.ExecApp: Add class #76
1 changed files with 6 additions and 0 deletions
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>
commit
104c6d9040
|
|
@ -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:]
|
||||
|
|
|
|||
Loading…
Reference in a new issue