From 0f036f799f7d881c34c637f857eeb9fa5ada594f Mon Sep 17 00:00:00 2001 From: Kot Date: Tue, 25 Apr 2023 19:05:57 -0700 Subject: [PATCH] Only list keys starting with `/` (#14) --- src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 1f129a0..02baf19 100644 --- a/src/index.ts +++ b/src/index.ts @@ -90,13 +90,13 @@ app.get('/', async (c) => { } let { prefix, cursor, limit: limitStr } = c.req.query() - prefix = prefix ? decodeURIComponent(prefix) : '' + prefix = prefix ? decodeURIComponent(prefix) : '/' cursor = cursor ? decodeURIComponent(cursor) : '' let limit = limitStr ? parseInt(decodeURIComponent(limitStr)) : 1000 let { keys, ...list } = await c.env.KV.list({ limit, - prefix, + prefix: prefix.startsWith('/') ? prefix : '/' + prefix, cursor, })