Commit 6af0848f authored by Admin's avatar Admin

fix: update path rewrite middleware to support new flat routes

parent 99ee01c4
...@@ -182,15 +182,10 @@ class CompanyPathRewriteMiddleware: ...@@ -182,15 +182,10 @@ class CompanyPathRewriteMiddleware:
company_id = match.group(2) company_id = match.group(2)
resource_path = match.group(3) resource_path = match.group(3)
# Only rewrite if it's one of the legacy compatibility paths # Check if this is a path we should NOT rewrite (runs API expects prefix)
is_legacy = ( is_runs = resource_path.startswith("runs")
resource_path.startswith("skills") or
resource_path.startswith("members") or
resource_path.startswith("user-directory") or
resource_path.startswith("join-requests")
)
if is_legacy: if not is_runs:
if resource_path.startswith("skills"): if resource_path.startswith("skills"):
resource_path = re.sub(r"^skills(\b|/)", "company-skills\\1", resource_path) resource_path = re.sub(r"^skills(\b|/)", "company-skills\\1", resource_path)
elif resource_path.startswith("members"): elif resource_path.startswith("members"):
...@@ -199,6 +194,8 @@ class CompanyPathRewriteMiddleware: ...@@ -199,6 +194,8 @@ class CompanyPathRewriteMiddleware:
resource_path = re.sub(r"^user-directory(\b|/)", "company-memberships/user-directory\\1", resource_path) resource_path = re.sub(r"^user-directory(\b|/)", "company-memberships/user-directory\\1", resource_path)
elif resource_path.startswith("join-requests"): elif resource_path.startswith("join-requests"):
resource_path = re.sub(r"^join-requests(\b|/)", "company-memberships/join-requests\\1", resource_path) resource_path = re.sub(r"^join-requests(\b|/)", "company-memberships/join-requests\\1", resource_path)
elif resource_path.startswith("org"):
resource_path = re.sub(r"^org(\b|/)", "org-chart-svg\\1", resource_path)
# Rewrite path # Rewrite path
scope["path"] = f"{api_prefix}/{resource_path}" scope["path"] = f"{api_prefix}/{resource_path}"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment