Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/treaty2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -270,7 +270,7 @@ const createProxy = (

q +=
(q ? '&' : '?') +
`${encodeURIComponent(key)}=${encodeURIComponent(
`${encodeURIComponent(key)}${isArray ? '[]' : ''}=${encodeURIComponent(
typeof value === 'object'
? JSON.stringify(value)
: value + ''
Expand All @@ -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)
Expand Down