From fc2cb4494663e4e32c64e86cb7140315b692e2d4 Mon Sep 17 00:00:00 2001 From: Diogo Biazus Date: Tue, 31 Oct 2023 22:15:08 -0400 Subject: [PATCH] Keys are also already decoded by URLSearchParams --- src/input-resolvers.test.ts | 4 ++-- src/input-resolvers.ts | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/input-resolvers.test.ts b/src/input-resolvers.test.ts index 51c7bf11..e475b29e 100644 --- a/src/input-resolvers.test.ts +++ b/src/input-resolvers.test.ts @@ -255,8 +255,8 @@ describe('inputFromSearch', () => { it('takes keys encoded as URI components', () => { const qs = new URLSearchParams() - qs.append('some%20colors[0]', 'blue') - qs.append('some%20colors[1]', 'red ish') + qs.append('some colors[0]', 'blue') + qs.append('some colors[1]', 'red ish') assertEquals(subject.inputFromSearch(qs), { 'some colors': ['blue', 'red ish'], }) diff --git a/src/input-resolvers.ts b/src/input-resolvers.ts index afccb403..7a8e176f 100644 --- a/src/input-resolvers.ts +++ b/src/input-resolvers.ts @@ -28,8 +28,7 @@ const inputFromSearch = (queryString: URLSearchParams) => { return pairs .sort(([keyA], [keyB]) => keyA.localeCompare(keyB)) - .reduce((parsed, [encodedKey, value]) => { - const key = decodeURIComponent(encodedKey) + .reduce((parsed, [key, value]) => { const compositeKey = key.match(/([^\[\]]*)(\[.*\].*)$/) if (compositeKey) { const [, rootKey, subKeys] = compositeKey