Skip to content

Commit

Permalink
fix: update parseStringArrayTypeQueryParams test
Browse files Browse the repository at this point in the history
  • Loading branch information
solufa committed Nov 14, 2024
1 parent 4d8d959 commit 31f9ba8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
4 changes: 1 addition & 3 deletions servers/all/$server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,7 @@ const parseStringArrayTypeQueryParams = (stringArrayTypeParams: [string, boolean
if (!isOptional && param === undefined) {
query[key] = [];
} else if (!isOptional || param !== undefined) {
const vals = (Array.isArray(param) ? param : [param]);

query[key] = vals;
query[key] = Array.isArray(param) ? param : [param];
}

delete query[`${key}[]`];
Expand Down
4 changes: 1 addition & 3 deletions src/buildServerFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ const parseStringArrayTypeQueryParams = (stringArrayTypeParams: [string, boolean
if (!isOptional && param === undefined) {
query[key] = [];
} else if (!isOptional || param !== undefined) {
const vals = (Array.isArray(param) ? param : [param]);
query[key] = vals;
query[key] = Array.isArray(param) ? param : [param];
}
delete query[\`\${key}[]\`];
Expand Down
4 changes: 2 additions & 2 deletions tests/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,12 @@ test('PUT: zod validations', async () => {
fetchClient.put({
query: {
requiredNum: 0,
requiredNumArr: [],
requiredNumArr: [1],
id: '1',
strArray: [],
disable: 'true',
bool: 1 as any,
boolArray: [],
boolArray: [true],
},
body: { port },
}),
Expand Down

0 comments on commit 31f9ba8

Please sign in to comment.