From edeb27b9f9cc5193c60c48cbbc427d7b2636caf0 Mon Sep 17 00:00:00 2001 From: Roland Bewick Date: Thu, 27 Jul 2023 15:15:50 +0700 Subject: [PATCH 1/2] fix: build query string util function double & --- src/utils.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils.ts b/src/utils.ts index b9a1075..78fce4f 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -6,6 +6,7 @@ export function buildQueryString(query: Record): string { ? `${key}=${value}` : "" ) + .filter(entry => entry) .join("&"); } From ab24c4d200a530da6ad6d31c655f21efcd546f09 Mon Sep 17 00:00:00 2001 From: Roland Bewick Date: Fri, 18 Aug 2023 17:06:51 +0700 Subject: [PATCH 2/2] fix: linting error --- src/utils.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index a5573f3..314fc19 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,12 +1,8 @@ // https://stackoverflow.com/a/62969380 + fix to remove empty entries (.filter(entry => entry)) -export function buildQueryString(query: Record): string { +export function buildQueryString(query: Record): string { return Object.entries(query) - .map(([key, value]) => - key && value - ? `${key}=${value}` - : "" - ) - .filter(entry => entry) + .map(([key, value]) => (key && value ? `${key}=${value}` : "")) + .filter((entry) => entry) .join("&"); }