8000 fix: disallow empty key (#134) · netlify/blobs@a8b4a23 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a8b4a23

Browse files
authored
fix: disallow empty key (#134)
1 parent b666247 commit a8b4a23

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/main.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,7 @@ describe('set', () => {
781781
siteID,
782782
})
783783

784+
expect(async () => await blobs.set('', 'value')).rejects.toThrowError('Blob key must not be empty.')
784785
expect(async () => await blobs.set('/key', 'value')).rejects.toThrowError(
785786
'Blob key must not start with forward slash (/).',
786787
)

src/store.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,10 @@ export class Store {
307307
}
308308

309309
private static validateKey(key: string) {
310+
if (key === '') {
311+
throw new Error('Blob key must not be empty.')
312+
}
313+
310314
if (key.startsWith('/') || key.startsWith('%2F')) {
311315
throw new Error('Blob key must not start with forward slash (/).')
312316
}

0 commit comments

Comments
 (0)
0