fix: Fix the url path pattern when generate nginx config

Fix the url path pattern when generate nginx config.

Closes-Bug: #1970007
Change-Id: Ifadfee974189f7b1426f29b20f6b23642a45bfee
This commit is contained in:
zhu.boxiang 2022-04-23 11:12:03 +08:00
parent 1ab2cec63b
commit e50d2a6bc5

View File

@ -91,12 +91,13 @@ def get_proxy_endpoints() -> Dict[str, ProxyEndpoint]:
if raw_url.path:
raw_path = PurePath(raw_url.path)
if len(raw_path.parts) > 1:
if (
raw_path.match("%(tenant_id)s")
or raw_path.match("AUTH_%(tenant_id)s")
or raw_path.match("$(project_id)s")
or raw_path.match("AUTH_$(project_id)s")
):
if raw_path.match("*[%$](*_id)s"):
# glob-style pattern: *, ?, [], [!], [-]
# The url of endpoint maybe like:
# 1. $(tenant_id)s or %(tenant_id)s
# 2. $(project_id)s or %(project_id)s
# 3. AUTH_$(tenant_id)s or AUTH_%(tenant_id)s
# 4. AUTH_$(project_id)s or AUTH_%(project_id)s
path = "" if str(raw_path.parents[1]) == "/" else raw_path.parents[1]
elif raw_path.match("v[0-9]") or raw_path.match("v[0-9][.][0-9]"):
path = "" if str(raw_path.parents[0]) == "/" else raw_path.parents[0]