diff --git a/datasette/views/base.py b/datasette/views/base.py index c11e6aef..0d34ba71 100644 --- a/datasette/views/base.py +++ b/datasette/views/base.py @@ -453,7 +453,7 @@ class DataView(BaseView): # _format may be in captured by the URL router as_format = kwargs.pop("as_format", None) if as_format: - _format = as_format + _format = as_format.lstrip(".") else: # If there's a '.' in the last portion of the path, use that as format: last_path_component = request.path.split("/")[-1] diff --git a/tests/test_api.py b/tests/test_api.py index ba7ec3c5..87363a84 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -681,7 +681,7 @@ def test_row(app_client): def test_row_strange_table_name(app_client): response = app_client.get( - "/fixtures/table-2Fwith-2Fslashes-2Ecsv/3.json?_shape=objects" + "/fixtures/table~2Fwith~2Fslashes~2Ecsv/3.json?_shape=objects" ) assert response.status == 200 assert [{"pk": "3", "content": "hey"}] == response.json["rows"]