From 6d8c435746c40b9867f11365ba5cfdaaa793fda4 Mon Sep 17 00:00:00 2001 From: Abi Hafshin Alfarouq Date: Thu, 19 Mar 2026 17:53:17 +0700 Subject: [PATCH 1/3] feat: allow passing array to query parameters --- src/treaty2/index.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/treaty2/index.ts b/src/treaty2/index.ts index e6cd5b3..bbe4387 100644 --- a/src/treaty2/index.ts +++ b/src/treaty2/index.ts @@ -261,7 +261,7 @@ const createProxy = ( let q = '' if (query) { - const append = (key: string, value: unknown) => { + const append = (key: string, value: unknown, isArray = false) => { // Explicitly exclude null and undefined values from url encoding // to prevent parsing string "null" / string "undefined" if (value === undefined || value === null) return @@ -270,7 +270,7 @@ const createProxy = ( q += (q ? '&' : '?') + - `${encodeURIComponent(key)}=${encodeURIComponent( + `${encodeURIComponent(key)}${isArray ? '[]' : ''}=${encodeURIComponent( typeof value === 'object' ? JSON.stringify(value) : value + '' @@ -279,9 +279,7 @@ const createProxy = ( for (const [key, value] of Object.entries(query)) { if (Array.isArray(value)) { - for (const v of value) append(key, v) - - continue + for (const v of value) append(key, v, true) } append(key, value) From 20236377c84dcaf4943d3a6858f61fa00348c1c4 Mon Sep 17 00:00:00 2001 From: Abi Hafshin Alfarouq Date: Thu, 19 Mar 2026 18:09:48 +0700 Subject: [PATCH 2/3] Add continue statement in query processing loop --- src/treaty2/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/treaty2/index.ts b/src/treaty2/index.ts index bbe4387..2608cda 100644 --- a/src/treaty2/index.ts +++ b/src/treaty2/index.ts @@ -280,6 +280,8 @@ const createProxy = ( for (const [key, value] of Object.entries(query)) { if (Array.isArray(value)) { for (const v of value) append(key, v, true) + + continue } append(key, value) From 2c46bf28599f263a5423f982d2b14351fc1a7dff Mon Sep 17 00:00:00 2001 From: Abi Hafshin Alfarouq Date: Thu, 19 Mar 2026 18:10:23 +0700 Subject: [PATCH 3/3] Fix indentation for continue statement --- src/treaty2/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/treaty2/index.ts b/src/treaty2/index.ts index 2608cda..6f0b885 100644 --- a/src/treaty2/index.ts +++ b/src/treaty2/index.ts @@ -281,7 +281,7 @@ const createProxy = ( if (Array.isArray(value)) { for (const v of value) append(key, v, true) - continue + continue } append(key, value)