Fix invalid repository paths from generated HTML

The "repository" in links from the generated HTML was only valid when
the URL did not contain a path component.
Resolve by supporting relative "repository".

This simplifies referencing the JSON from a generated HTML since
a relative link doesn't need to know the repositories absolute URL
to the destination.
This commit is contained in:
Campbell Barton
2024-07-01 23:21:21 +10:00
parent d4774a219b
commit 0255be9b22
2 changed files with 10 additions and 1 deletions

View File

@@ -476,6 +476,15 @@ def url_parse_for_blender(url: str) -> Tuple[str, Dict[str, str]]:
None, # `parsed_url.query,`
None, # `parsed_url.fragment,`
))
elif value.startswith("./"):
value_xform = urllib.parse.urlunparse((
parsed_url.scheme,
parsed_url.netloc,
parsed_url.path.rsplit("/", 1)[0] + value[1:],
None, # `parsed_url.params,`
None, # `parsed_url.query,`
None, # `parsed_url.fragment,`
))
else:
value_xform = value
if value_xform is not None:

View File

@@ -2787,7 +2787,7 @@ class subcmd_server:
parsed_url = urllib.parse.urlparse(manifest_dict["archive_url"])
# We could support existing values, currently always empty.
# `query = dict(urllib.parse.parse_qsl(parsed_url.query))`
query = {"repository": "/index.json"}
query = {"repository": "./index.json"}
if (value := manifest_dict.get("blender_version_min", "")):
query["blender_version_min"] = value
if (value := manifest_dict.get("blender_version_max", "")):