Handle paths relative to a file in urlresolve

This commit is contained in:
Lucidiot 2021-02-08 21:03:06 +00:00
parent 789c0445d4
commit c6437afc86
Signed by: lucidiot
GPG Key ID: 3358C1CA6906FB8D
1 changed files with 2 additions and 2 deletions

View File

@ -30,9 +30,9 @@ def urlresolve(base):
.scheme = $parsedbase.scheme
| .netloc = $parsedbase.netloc
# When the path does not start with a slash, make it relative to the base's path
# Note that this assumes the base URL always points to a folder, even if it does not end with a /
# by removing the filename from the base's path and appending the path
| if .path|startswith("/")|not then (
.path = (($parsedbase.path|rtrimstr("/")) + "/" + ($parsed.path|ltrimstr("/")))
.path = (($parsedbase.path|split("/")[:-1]|join("/")) + "/" + ($parsed.path|ltrimstr("/")))
) else . end
) elif (.query // .fragment) then (
.scheme = $parsedbase.scheme