Skip to content

Commit 6aee695

Browse files
authored
Fix empty querystring params
ArangoDB likes to choke on these.
1 parent 735db9a commit 6aee695

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/connection.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ function isSystemError(err: Error): err is SystemError {
3030
);
3131
}
3232

33+
function clean<T>(obj: T) {
34+
const result = {} as typeof obj;
35+
for (const key of Object.keys(obj)) {
36+
const value = (obj as any)[key];
37+
if (value === undefined) continue;
38+
(result as any)[key] = value;
39+
}
40+
return result;
41+
}
42+
3343
type UrlInfo = {
3444
absolutePath?: boolean;
3545
basePath?: string;
@@ -229,7 +239,7 @@ export class Connection {
229239
if (path) pathname += path;
230240
if (qs) {
231241
if (typeof qs === "string") search = `?${qs}`;
232-
else search = `?${querystringify(qs)}`;
242+
else search = `?${querystringify(clean(qs))}`;
233243
}
234244
return search ? { pathname, search } : { pathname };
235245
}

0 commit comments

Comments
 (0)