Skip to content

Commit

Permalink
fix issue 34
Browse files Browse the repository at this point in the history
  • Loading branch information
UrielCh committed Sep 11, 2024
1 parent 1e7e4a0 commit d221d83
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions api/src/ProxmoxEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ export class ProxmoxEngine implements ApiRequestable {
searchParams.set(k, '1');
else if (v === false)
searchParams.set(k, '0');
else if (Array.isArray(v))
for (const e of v)
searchParams.append(k, `${e}`);
else
searchParams.set(k, `${v}`);
}
Expand Down
7 changes: 5 additions & 2 deletions api/src/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,13 @@ test("test", async (t) => {
// console.log(myfetch.options.body);

const qemu = theNode.qemu.$(100);
await qemu.agent.exec.$post({ command: ["touch", "/test"] });
const post = qemu.agent.exec.$post;
await post({ command: ["touch", "/test"] });
assert.strictEqual(
myfetch.url,
"https://127.0.0.1/api2/json/nodes/node1/qemu/100/agent/exec",
);
assert.strictEqual(myfetch.options.body, "command=touch%2C%2Ftest");
// old: "command=touch%2C%2Ftest"
// new: "command=touch&command=%2Ftest"
assert.strictEqual(myfetch.options.body, "command=touch&command=%2Ftest", "array parammeter should be passed as mutiple values");
});

0 comments on commit d221d83

Please sign in to comment.