fix: tilde encode database name in expanded foreign key links (#2476)

* Tilde encode database for expanded foreign key links
* Test for foreign key fix in #2476

---------

Co-authored-by: Simon Willison <swillison@gmail.com>
This commit is contained in:
Jack Stratton 2025-04-16 22:15:11 -07:00 committed by GitHub
commit d5c6e502fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View file

@ -3,6 +3,7 @@ from bs4 import BeautifulSoup as Soup
from .fixtures import ( # noqa
app_client,
make_app_client,
app_client_with_dot,
)
import pathlib
import pytest
@ -1291,3 +1292,9 @@ async def test_foreign_key_labels_obey_permissions(config):
"rows": [{"id": 1, "name": "world", "a_id": 1}],
"truncated": False,
}
def test_foreign_keys_special_character_in_database_name(app_client_with_dot):
# https://github.com/simonw/datasette/pull/2476
response = app_client_with_dot.get("/fixtures~2Edot/complex_foreign_keys")
assert '<a href="/fixtures~2Edot/simple_primary_key/2">world</a>' in response.text