From 72bcdf283473dc350be4a82db716ecca3989f2cf Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Sat, 12 Dec 2020 14:24:30 +0100 Subject: [PATCH] fix: getParams object keys --- src/index.ts | 2 +- test/params.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index e06b73f9..1f11cfbe 100644 --- a/src/index.ts +++ b/src/index.ts @@ -63,7 +63,7 @@ export function withParams (input: InputURL, params: SearchParams): string { export function getParams (input: InputURL): SearchParams { const parsed = parseURL(input) const params: SearchParams = {} - parsed.url.searchParams.forEach((value, key) => { params[value] = key }) + parsed.url.searchParams.forEach((value, key) => { params[key] = value }) return params } diff --git a/test/params.test.ts b/test/params.test.ts index 72a90860..ffc2d7c8 100644 --- a/test/params.test.ts +++ b/test/params.test.ts @@ -20,7 +20,7 @@ describe('withParams', () => { describe('getParams', () => { const tests = { - 'http://foo.com/foo?test=123&unicode=%E5%A5%BD': { 123: 'test', 好: 'unicode' } + 'http://foo.com/foo?test=123&unicode=%E5%A5%BD': { test: '123', unicode: '好' } } for (const t in tests) {