mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-24 16:32:29 +00:00
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { splitArgsPreservingQuotes } from "./arg-split.js";
|
|
|
|
describe("splitArgsPreservingQuotes", () => {
|
|
it("splits on whitespace outside quotes", () => {
|
|
expect(splitArgsPreservingQuotes('/usr/bin/openclaw gateway start --name "My Bot"')).toEqual([
|
|
"/usr/bin/openclaw",
|
|
"gateway",
|
|
"start",
|
|
"--name",
|
|
"My Bot",
|
|
]);
|
|
});
|
|
|
|
it("supports systemd-style backslash escaping", () => {
|
|
expect(
|
|
splitArgsPreservingQuotes('openclaw --name "My \\"Bot\\"" --foo bar', {
|
|
escapeMode: "backslash",
|
|
}),
|
|
).toEqual(["openclaw", "--name", 'My "Bot"', "--foo", "bar"]);
|
|
});
|
|
|
|
it("supports schtasks-style escaped quotes while preserving other backslashes", () => {
|
|
expect(
|
|
splitArgsPreservingQuotes('openclaw --path "C:\\\\Program Files\\\\OpenClaw"', {
|
|
escapeMode: "backslash-quote-only",
|
|
}),
|
|
).toEqual(["openclaw", "--path", "C:\\\\Program Files\\\\OpenClaw"]);
|
|
|
|
expect(
|
|
splitArgsPreservingQuotes('openclaw --label "My \\"Quoted\\" Name"', {
|
|
escapeMode: "backslash-quote-only",
|
|
}),
|
|
).toEqual(["openclaw", "--label", 'My "Quoted" Name']);
|
|
});
|
|
});
|