-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Expand file tree
/
Copy pathcmd-escape-issue.test.js
More file actions
53 lines (46 loc) · 1.48 KB
/
cmd-escape-issue.test.js
File metadata and controls
53 lines (46 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
* @prettier
*/
import Im from "immutable"
import {
requestSnippetGenerator_curl_bash,
requestSnippetGenerator_curl_cmd,
requestSnippetGenerator_curl_powershell
} from "core/plugins/request-snippets/fn.js"
describe("curlify - CMD pipe escaping (issue #10540)", function () {
it("escapes pipe in CMD request body", function () {
const req = {
url: "http://example.com/api",
method: "POST",
body: "data|with|pipes",
headers: {}
}
const curlified = requestSnippetGenerator_curl_cmd(Im.fromJS(req))
expect(curlified).toContain("data^|with^|pipes")
})
it("escapes pipe in CMD URL and header", function () {
const req = {
url: "http://example.com/api?name=john|smith",
method: "GET",
headers: {
"X-Custom": "value|with|pipe"
}
}
const curlified = requestSnippetGenerator_curl_cmd(Im.fromJS(req))
expect(curlified).toContain("john^|smith")
expect(curlified).toContain("value^|with^|pipe")
})
it("keeps bash and powershell behavior unchanged", function () {
const req = {
url: "http://example.com/api?name=john|smith",
method: "GET",
headers: {}
}
const bashResult = requestSnippetGenerator_curl_bash(Im.fromJS(req))
const psResult = requestSnippetGenerator_curl_powershell(Im.fromJS(req))
expect(bashResult).toContain("john|smith")
expect(psResult).toContain("john|smith")
expect(bashResult).not.toContain("^|")
expect(psResult).not.toContain("^|")
})
})