Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Note: Minor version `0.X.0` update might break the API, It's recommended to pin
### fixed

- forward `catalog_dependency` in `OGCFeaturesFactory` and `OGCTilesFactory` when using `Endpoints` factory
- allow Factory's prefix with path parameter

### changed

Expand Down
11 changes: 10 additions & 1 deletion tipg/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
from starlette.datastructures import QueryParams
from starlette.requests import Request
from starlette.responses import HTMLResponse, Response, StreamingResponse
from starlette.routing import compile_path, replace_params
from starlette.templating import Jinja2Templates, _TemplateResponse

tms_settings = TMSSettings()
Expand Down Expand Up @@ -226,7 +227,15 @@ def url_for(self, request: Request, name: str, **path_params: Any) -> str:

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