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

@ -453,6 +453,12 @@ def test_path_with_format(path, format, extra_qs, expected):
assert expected == actual
def test_path_with_format_can_override_request_path():
request = Request.fake("/prefix/foo?x=1")
actual = utils.path_with_format(request=request, path="/foo", format="json")
assert "/foo.json?x=1" == actual
@pytest.mark.parametrize(
"bytes,expected",
[