This commit is contained in:
Simon Willison 2019-10-18 15:18:24 -07:00
commit 1186ca1eac

View file

@ -193,14 +193,14 @@ class DataView(BaseView):
async def resolve_db_name(self, request, db_name, **kwargs): async def resolve_db_name(self, request, db_name, **kwargs):
hash = None hash = None
name = None name = None
if "-" in db_name: if db_name not in self.ds.databases and "-" in db_name:
# Might be name-and-hash, or might just be # No matching DB found, maybe it's a name-hash?
# a name with a hyphen in it name_bit, hash_bit = db_name.rsplit("-", 1)
name, hash = db_name.rsplit("-", 1) if name_bit not in self.ds.databases:
if name not in self.ds.databases: raise NotFound("Database not found: {}".format(name))
# Try the whole name else:
name = db_name name = name_bit
hash = None hash = hash_bit
else: else:
name = db_name name = db_name
# Verify the hash # Verify the hash