Skip to content
Open
Changes from all commits
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
6 changes: 3 additions & 3 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,7 +279,7 @@ const createProxy = (

for (const [key, value] of Object.entries(query)) {
if (Array.isArray(value)) {
for (const v of value) append(key, v)
for (const v of value) append(key, v, true)

continue
}
Expand Down