mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Handle databases with spaces in their names
This commit is contained in:
parent
a9453c4dda
commit
4fdbeb4924
3 changed files with 13 additions and 0 deletions
|
|
@ -203,6 +203,8 @@ class DataView(BaseView):
|
||||||
hash = None
|
hash = None
|
||||||
else:
|
else:
|
||||||
name = db_name
|
name = db_name
|
||||||
|
if "%" in name:
|
||||||
|
name = urllib.parse.unquote_plus(name)
|
||||||
# Verify the hash
|
# Verify the hash
|
||||||
try:
|
try:
|
||||||
db = self.ds.databases[name]
|
db = self.ds.databases[name]
|
||||||
|
|
|
||||||
|
|
@ -215,6 +215,11 @@ def app_client_with_dot():
|
||||||
yield from make_app_client(filename="fixtures.dot.db")
|
yield from make_app_client(filename="fixtures.dot.db")
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope="session")
|
||||||
|
def app_client_with_space():
|
||||||
|
yield from make_app_client(filename="fixtures with space.db")
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="session")
|
@pytest.fixture(scope="session")
|
||||||
def app_client_with_cors():
|
def app_client_with_cors():
|
||||||
yield from make_app_client(cors=True)
|
yield from make_app_client(cors=True)
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ from .fixtures import ( # noqa
|
||||||
app_client_two_attached_databases_one_immutable,
|
app_client_two_attached_databases_one_immutable,
|
||||||
app_client_with_cors,
|
app_client_with_cors,
|
||||||
app_client_with_dot,
|
app_client_with_dot,
|
||||||
|
app_client_with_space,
|
||||||
generate_compound_rows,
|
generate_compound_rows,
|
||||||
generate_sortable_rows,
|
generate_sortable_rows,
|
||||||
make_app_client,
|
make_app_client,
|
||||||
|
|
@ -544,6 +545,11 @@ def test_database_page_for_database_with_dot_in_name(app_client_with_dot):
|
||||||
assert 200 == response.status
|
assert 200 == response.status
|
||||||
|
|
||||||
|
|
||||||
|
def test_database_page_for_database_with_space_in_name(app_client_with_space):
|
||||||
|
response = app_client_with_space.get("/fixtures%20with%20space.json")
|
||||||
|
assert 200 == response.status
|
||||||
|
|
||||||
|
|
||||||
def test_custom_sql(app_client):
|
def test_custom_sql(app_client):
|
||||||
response = app_client.get(
|
response = app_client.get(
|
||||||
"/fixtures.json?sql=select+content+from+simple_primary_key&_shape=objects"
|
"/fixtures.json?sql=select+content+from+simple_primary_key&_shape=objects"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue