Fix double-prefixed export links with base_url

Use the router-stripped route_path when building request-derived export
URLs, so table, row, and query JSON/CSV links do not apply base_url twice.

Keep urls.path() behavior unchanged, and add coverage for both /prefix/
exports and a /data/ base_url with a data database.

Closes #2759
This commit is contained in:
Simon Willison 2026-05-30 22:40:45 -07:00
commit d657fb4315
7 changed files with 118 additions and 11 deletions

View file

@ -837,7 +837,8 @@ def path_with_format(
*, request=None, path=None, format=None, extra_qs=None, replace_format=None
):
qs = extra_qs or {}
path = request.path if request else path
if path is None and request:
path = request.path
if replace_format and path.endswith(f".{replace_format}"):
path = path[: -(1 + len(replace_format))]
if "." in path: