mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-21 08:21:19 +02:00
Fix split in curl importer
https://feedback.yaak.app/p/import-from-curl-does-not-work-properly-sometimes
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { HttpRequest, Workspace } from '@yaakapp/api';
|
||||
import type { HttpRequest, Workspace } from '@yaakapp/api';
|
||||
import { describe, expect, test } from 'vitest';
|
||||
import { convertCurl } from '../src';
|
||||
|
||||
@@ -221,20 +221,20 @@ describe('importer-curl', () => {
|
||||
});
|
||||
|
||||
test('Imports post data into URL', () => {
|
||||
expect(
|
||||
convertCurl('curl -G https://api.stripe.com/v1/payment_links -d limit=3'),
|
||||
).toEqual({
|
||||
expect(convertCurl('curl -G https://api.stripe.com/v1/payment_links -d limit=3')).toEqual({
|
||||
resources: {
|
||||
workspaces: [baseWorkspace()],
|
||||
httpRequests: [
|
||||
baseRequest({
|
||||
method: 'GET',
|
||||
url: 'https://api.stripe.com/v1/payment_links',
|
||||
urlParameters: [{
|
||||
enabled: true,
|
||||
name: 'limit',
|
||||
value: '3',
|
||||
}],
|
||||
urlParameters: [
|
||||
{
|
||||
enabled: true,
|
||||
name: 'limit',
|
||||
value: '3',
|
||||
},
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
@@ -243,7 +243,9 @@ describe('importer-curl', () => {
|
||||
|
||||
test('Imports multi-line JSON', () => {
|
||||
expect(
|
||||
convertCurl(`curl -H Content-Type:application/json -d $'{\n "foo":"bar"\n}' https://yaak.app`),
|
||||
convertCurl(
|
||||
`curl -H Content-Type:application/json -d $'{\n "foo":"bar"\n}' https://yaak.app`,
|
||||
),
|
||||
).toEqual({
|
||||
resources: {
|
||||
workspaces: [baseWorkspace()],
|
||||
@@ -364,6 +366,31 @@ describe('importer-curl', () => {
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
test('Imports weird body', () => {
|
||||
expect(convertCurl(`curl 'https://yaak.app' -X POST --data-raw 'foo=bar=baz'`)).toEqual({
|
||||
resources: {
|
||||
workspaces: [baseWorkspace()],
|
||||
httpRequests: [
|
||||
baseRequest({
|
||||
url: 'https://yaak.app',
|
||||
method: "POST",
|
||||
bodyType: 'application/x-www-form-urlencoded',
|
||||
body: {
|
||||
form: [{ name: 'foo', value: 'bar=baz', enabled: true }],
|
||||
},
|
||||
headers: [
|
||||
{
|
||||
enabled: true,
|
||||
name: 'Content-Type',
|
||||
value: 'application/x-www-form-urlencoded',
|
||||
},
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
const idCount: Partial<Record<string, number>> = {};
|
||||
|
||||
Reference in New Issue
Block a user