Fixed bug loading database called 'test-database (1).sqlite'

Closes #1181.

Also now ensures that database URLs have special characters URL-quoted.
This commit is contained in:
Simon Willison 2021-01-24 21:13:05 -08:00
commit a5ede3cdd4
7 changed files with 55 additions and 27 deletions

View file

@ -30,9 +30,11 @@ class Urls:
def database(self, database, format=None):
db = self.ds.databases[database]
if self.ds.setting("hash_urls") and db.hash:
path = self.path(f"{database}-{db.hash[:HASH_LENGTH]}", format=format)
path = self.path(
f"{urllib.parse.quote(database)}-{db.hash[:HASH_LENGTH]}", format=format
)
else:
path = self.path(database, format=format)
path = self.path(urllib.parse.quote(database), format=format)
return path
def table(self, database, table, format=None):