diff --git a/src/main.test.ts b/src/main.test.ts index 6c71934..140f5d5 100644 --- a/src/main.test.ts +++ b/src/main.test.ts @@ -781,6 +781,7 @@ describe('set', () => { siteID, }) + expect(async () => await blobs.set('', 'value')).rejects.toThrowError('Blob key must not be empty.') expect(async () => await blobs.set('/key', 'value')).rejects.toThrowError( 'Blob key must not start with forward slash (/).', ) diff --git a/src/store.ts b/src/store.ts index 9a085f2..1e0aa23 100644 --- a/src/store.ts +++ b/src/store.ts @@ -307,6 +307,10 @@ export class Store { } private static validateKey(key: string) { + if (key === '') { + throw new Error('Blob key must not be empty.') + } + if (key.startsWith('/') || key.startsWith('%2F')) { throw new Error('Blob key must not start with forward slash (/).') }