Skip to content

Commit

Permalink
do not change mutable (#693)
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentsarago authored Aug 27, 2023
1 parent e6f7e4c commit 0d5b433
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes

## 0.13.3 (2023-08-27)

- fix Factories `url_for` method and avoid changing `Request.path_params` object

## 0.13.2 (2023-08-24)

### titiler.extensions
Expand Down
12 changes: 10 additions & 2 deletions src/titiler/core/titiler/core/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def url_for(self, request: Request, name: str, **path_params: Any) -> str:
if "{" in prefix:
_, path_format, param_convertors = compile_path(prefix)
prefix, _ = replace_params(
path_format, param_convertors, request.path_params
path_format, param_convertors, request.path_params.copy()
)
base_url += prefix

Expand Down Expand Up @@ -1575,7 +1575,15 @@ def url_for(self, request: Request, name: str, **path_params: Any) -> str:
url_path = self.router.url_path_for(name, **path_params)
base_url = str(request.base_url)
if self.router_prefix:
base_url += self.router_prefix.lstrip("/")
prefix = self.router_prefix.lstrip("/")
# If we have prefix with custom path param we check and replace them with
# the path params provided
if "{" in prefix:
_, path_format, param_convertors = compile_path(prefix)
prefix, _ = replace_params(
path_format, param_convertors, request.path_params.copy()
)
base_url += prefix

return str(url_path.make_absolute_url(base_url=base_url))

Expand Down

0 comments on commit 0d5b433

Please sign in to comment.