Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

fix: strip backslashes from curl when paste (#3376)

Bogdan Chadkin2fd7c6d30702
diff --git a/apps/builder/app/builder/features/settings-panel/curl.test.ts b/apps/builder/app/builder/features/settings-panel/curl.test.ts
index 5e604f457e..bf82d7b7b0 100644
--- a/apps/builder/app/builder/features/settings-panel/curl.test.ts
+++ b/apps/builder/app/builder/features/settings-panel/curl.test.ts
@@ -12,9 +12,9 @@ test("support url", () => {
expect(parseCurl(`curl 'https://my-url/hello-world'`)).toEqual(result);
});
-test("support multiline", () => {
+test("support multiline command with backslashes", () => {
expect(
- parseCurl(`curl \
+ parseCurl(`curl \\
'https://my-url/hello-world'
`)
).toEqual({
@@ -114,9 +114,7 @@ test("support text body with explicit method", () => {
test("support json body", () => {
expect(
parseCurl(
- `curl https://my-url/hello-world \
- --header 'content-type: application/json' \
- --data '{"param":"value"}'`
+ `curl https://my-url/hello-world --header 'content-type: application/json' --data '{"param":"value"}'`
)
).toEqual({
url: "https://my-url/hello-world",
diff --git a/apps/builder/app/builder/features/settings-panel/curl.ts b/apps/builder/app/builder/features/settings-panel/curl.ts
index 61e2bdadad..36948f684e 100644
--- a/apps/builder/app/builder/features/settings-panel/curl.ts
+++ b/apps/builder/app/builder/features/settings-panel/curl.ts
@@ -30,6 +30,9 @@ export type CurlRequest = Pick<
>;
export const parseCurl = (curl: string): undefined | CurlRequest => {
+ // remove backslash followed by newline
+ // https://github.com/astur/arrgv/issues/3
+ curl = curl.replaceAll(/\\(?=\s)/g, "");
let argv;
try {
argv = arrgv(curl);