mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-06-28 02:53:30 +00:00
fix: regex pattern matching to support :path suffix in the routes (#1089)
This PR fixes client sdk test failure --
3720312204
by updating the regex matching pattern to also consider `:path` in the
routes
This commit is contained in:
parent
da53dc3f5f
commit
b0b696cb4f
1 changed files with 7 additions and 1 deletions
|
@ -231,7 +231,13 @@ class AsyncLlamaStackAsLibraryClient(AsyncLlamaStackClient):
|
||||||
|
|
||||||
def _convert_path_to_regex(path: str) -> str:
|
def _convert_path_to_regex(path: str) -> str:
|
||||||
# Convert {param} to named capture groups
|
# Convert {param} to named capture groups
|
||||||
pattern = re.sub(r"{(\w+)}", r"(?P<\1>[^/]+)", path)
|
# handle {param:path} as well which allows for forward slashes in the param value
|
||||||
|
pattern = re.sub(
|
||||||
|
r"{(\w+)(?::path)?}",
|
||||||
|
lambda m: f"(?P<{m.group(1)}>{'[^/]+' if not m.group(0).endswith(':path') else '.+'})",
|
||||||
|
path,
|
||||||
|
)
|
||||||
|
|
||||||
return f"^{pattern}$"
|
return f"^{pattern}$"
|
||||||
|
|
||||||
for api, api_endpoints in endpoints.items():
|
for api, api_endpoints in endpoints.items():
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue