@readme/httpsnippet 10.1.1 → 11.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { CodeBuilder } from './chunk-Y7NI4MMY.js';
2
- import stringifyObject9 from 'stringify-object';
1
+ import { CodeBuilder } from './chunk-6B3J3CUI.js';
2
+ import stringifyObject7 from 'stringify-object';
3
3
 
4
4
  // src/helpers/escape.ts
5
5
  function escapeString(rawValue, options = {}) {
@@ -432,7 +432,7 @@ var restsharp = {
432
432
  link: "http://restsharp.org/",
433
433
  description: "Simple REST and HTTP API Client for .NET",
434
434
  extname: ".cs",
435
- installation: "dotnet add package RestSharp"
435
+ installation: () => "dotnet add package RestSharp"
436
436
  },
437
437
  convert: ({ method, fullUrl, headersObj, cookies, postData, uriObj }) => {
438
438
  const { push, join } = new CodeBuilder();
@@ -841,7 +841,7 @@ var axios = {
841
841
  link: "https://github.com/axios/axios",
842
842
  description: "Promise based HTTP client for the browser and node.js",
843
843
  extname: ".js",
844
- installation: "npm install axios --save"
844
+ installation: () => "npm install axios --save"
845
845
  },
846
846
  convert: ({ allHeaders, method, url, queryObj, postData }, options) => {
847
847
  const opts = {
@@ -894,7 +894,7 @@ var axios = {
894
894
  requestOptions.data = postData.text;
895
895
  }
896
896
  }
897
- const optionString = stringifyObject9(requestOptions, {
897
+ const optionString = stringifyObject7(requestOptions, {
898
898
  indent: " ",
899
899
  inlineCharacterLimit: 80
900
900
  }).replace('"[form]"', "form");
@@ -902,12 +902,8 @@ var axios = {
902
902
  blank();
903
903
  push("axios");
904
904
  push(".request(options)", 1);
905
- push(".then(function (response) {", 1);
906
- push("console.log(response.data);", 2);
907
- push("})", 1);
908
- push(".catch(function (error) {", 1);
909
- push("console.error(error);", 2);
910
- push("});", 1);
905
+ push(".then(res => console.log(res.data))", 1);
906
+ push(".catch(err => console.error(err));", 1);
911
907
  return join();
912
908
  }
913
909
  };
@@ -944,7 +940,7 @@ var fetch = {
944
940
  options.body = postData.jsonObj;
945
941
  }
946
942
  break;
947
- case "multipart/form-data":
943
+ case "multipart/form-data": {
948
944
  if (!postData.params) {
949
945
  break;
950
946
  }
@@ -958,6 +954,7 @@ var fetch = {
958
954
  });
959
955
  blank();
960
956
  break;
957
+ }
961
958
  default:
962
959
  if (postData.text) {
963
960
  options.body = postData.text;
@@ -967,7 +964,7 @@ var fetch = {
967
964
  delete options.headers;
968
965
  }
969
966
  push(
970
- `const options = ${stringifyObject9(options, {
967
+ `const options = ${stringifyObject7(options, {
971
968
  indent: opts.indent,
972
969
  inlineCharacterLimit: 80,
973
970
  // The Fetch API body only accepts string parameters, but stringified JSON can be difficult
@@ -991,8 +988,8 @@ var fetch = {
991
988
  blank();
992
989
  }
993
990
  push(`fetch('${fullUrl}', options)`);
994
- push(".then(response => response.json())", 1);
995
- push(".then(response => console.log(response))", 1);
991
+ push(".then(res => res.json())", 1);
992
+ push(".then(res => console.log(res))", 1);
996
993
  push(".catch(err => console.error(err));", 1);
997
994
  return join();
998
995
  }
@@ -1053,11 +1050,11 @@ var jquery = {
1053
1050
  settings.data = postData.text;
1054
1051
  }
1055
1052
  }
1056
- const stringifiedSettings = stringifyObject9(settings, { indent: opts.indent }).replace("'[form]'", "form");
1053
+ const stringifiedSettings = stringifyObject7(settings, { indent: opts.indent }).replace("'[form]'", "form");
1057
1054
  push(`const settings = ${stringifiedSettings};`);
1058
1055
  blank();
1059
- push("$.ajax(settings).done(function (response) {");
1060
- push("console.log(response);", 1);
1056
+ push("$.ajax(settings).done(res => {");
1057
+ push("console.log(res);", 1);
1061
1058
  push("});");
1062
1059
  return join();
1063
1060
  }
@@ -1080,7 +1077,7 @@ var xhr = {
1080
1077
  switch (postData.mimeType) {
1081
1078
  case "application/json":
1082
1079
  push(
1083
- `const data = JSON.stringify(${stringifyObject9(postData.jsonObj, {
1080
+ `const data = JSON.stringify(${stringifyObject7(postData.jsonObj, {
1084
1081
  indent: opts.indent
1085
1082
  })});`
1086
1083
  );
@@ -1134,7 +1131,7 @@ var javascript = {
1134
1131
  info: {
1135
1132
  key: "javascript",
1136
1133
  title: "JavaScript",
1137
- default: "xhr"
1134
+ default: "fetch"
1138
1135
  },
1139
1136
  clientsById: {
1140
1137
  xhr,
@@ -1168,7 +1165,7 @@ var native2 = {
1168
1165
  payload = postData.jsonObj;
1169
1166
  }
1170
1167
  break;
1171
- case "multipart/form-data":
1168
+ case "multipart/form-data": {
1172
1169
  if (!postData.params) {
1173
1170
  break;
1174
1171
  }
@@ -1178,6 +1175,7 @@ var native2 = {
1178
1175
  });
1179
1176
  payload = multipartPayload;
1180
1177
  break;
1178
+ }
1181
1179
  default:
1182
1180
  if (postData.text) {
1183
1181
  payload = postData.text;
@@ -1273,8 +1271,8 @@ var axios2 = {
1273
1271
  title: "Axios",
1274
1272
  link: "https://github.com/axios/axios",
1275
1273
  description: "Promise based HTTP client for the browser and node.js",
1276
- extname: ".cjs",
1277
- installation: "npm install axios --save"
1274
+ extname: ".js",
1275
+ installation: () => "npm install axios --save"
1278
1276
  },
1279
1277
  convert: ({ method, fullUrl, allHeaders, postData }, options) => {
1280
1278
  const opts = {
@@ -1282,7 +1280,8 @@ var axios2 = {
1282
1280
  ...options
1283
1281
  };
1284
1282
  const { blank, join, push, addPostProcessor } = new CodeBuilder({ indent: opts.indent });
1285
- push("const axios = require('axios');");
1283
+ push("import axios from 'axios';");
1284
+ blank();
1286
1285
  const reqOpts = {
1287
1286
  method,
1288
1287
  url: fullUrl
@@ -1293,8 +1292,6 @@ var axios2 = {
1293
1292
  switch (postData.mimeType) {
1294
1293
  case "application/x-www-form-urlencoded":
1295
1294
  if (postData.params) {
1296
- push("const { URLSearchParams } = require('url');");
1297
- blank();
1298
1295
  push("const encodedParams = new URLSearchParams();");
1299
1296
  postData.params.forEach((param) => {
1300
1297
  push(`encodedParams.set('${param.name}', '${param.value}');`);
@@ -1305,39 +1302,32 @@ var axios2 = {
1305
1302
  }
1306
1303
  break;
1307
1304
  case "application/json":
1308
- blank();
1309
1305
  if (postData.jsonObj) {
1310
1306
  reqOpts.data = postData.jsonObj;
1311
1307
  }
1312
1308
  break;
1313
1309
  default:
1314
- blank();
1315
1310
  if (postData.text) {
1316
1311
  reqOpts.data = postData.text;
1317
1312
  }
1318
1313
  }
1319
- const stringifiedOptions = stringifyObject9(reqOpts, { indent: " ", inlineCharacterLimit: 80 });
1314
+ const stringifiedOptions = stringifyObject7(reqOpts, { indent: " ", inlineCharacterLimit: 80 });
1320
1315
  push(`const options = ${stringifiedOptions};`);
1321
1316
  blank();
1322
1317
  push("axios");
1323
1318
  push(".request(options)", 1);
1324
- push(".then(function (response) {", 1);
1325
- push("console.log(response.data);", 2);
1326
- push("})", 1);
1327
- push(".catch(function (error) {", 1);
1328
- push("console.error(error);", 2);
1329
- push("});", 1);
1319
+ push(".then(res => console.log(res.data))", 1);
1320
+ push(".catch(err => console.error(err));", 1);
1330
1321
  return join();
1331
1322
  }
1332
1323
  };
1333
1324
  var fetch2 = {
1334
1325
  info: {
1335
1326
  key: "fetch",
1336
- title: "Fetch",
1337
- link: "https://github.com/bitinn/node-fetch",
1338
- description: "Simplified HTTP node-fetch client",
1339
- extname: ".cjs",
1340
- installation: "npm install node-fetch@2 --save"
1327
+ title: "fetch",
1328
+ link: "https://nodejs.org/docs/latest/api/globals.html#fetch",
1329
+ description: "Perform asynchronous HTTP requests with the Fetch API",
1330
+ extname: ".js"
1341
1331
  },
1342
1332
  convert: ({ method, fullUrl, postData, headersObj, cookies }, options) => {
1343
1333
  const opts = {
@@ -1346,7 +1336,6 @@ var fetch2 = {
1346
1336
  };
1347
1337
  let includeFS = false;
1348
1338
  const { blank, push, join, unshift } = new CodeBuilder({ indent: opts.indent });
1349
- push("const fetch = require('node-fetch');");
1350
1339
  const url = fullUrl;
1351
1340
  const reqOpts = {
1352
1341
  method
@@ -1356,20 +1345,19 @@ var fetch2 = {
1356
1345
  }
1357
1346
  switch (postData.mimeType) {
1358
1347
  case "application/x-www-form-urlencoded":
1359
- unshift("const { URLSearchParams } = require('url');");
1360
1348
  push("const encodedParams = new URLSearchParams();");
1361
- blank();
1362
1349
  postData.params?.forEach((param) => {
1363
1350
  push(`encodedParams.set('${param.name}', '${param.value}');`);
1364
1351
  });
1365
1352
  reqOpts.body = "encodedParams";
1353
+ blank();
1366
1354
  break;
1367
1355
  case "application/json":
1368
1356
  if (postData.jsonObj) {
1369
1357
  reqOpts.body = postData.jsonObj;
1370
1358
  }
1371
1359
  break;
1372
- case "multipart/form-data":
1360
+ case "multipart/form-data": {
1373
1361
  if (!postData.params) {
1374
1362
  break;
1375
1363
  }
@@ -1377,9 +1365,7 @@ var fetch2 = {
1377
1365
  if (contentTypeHeader) {
1378
1366
  delete headersObj[contentTypeHeader];
1379
1367
  }
1380
- unshift("const FormData = require('form-data');");
1381
1368
  push("const formData = new FormData();");
1382
- blank();
1383
1369
  postData.params.forEach((param) => {
1384
1370
  if (!param.fileName && !param.fileName && !param.contentType) {
1385
1371
  push(`formData.append('${param.name}', '${param.value}');`);
@@ -1387,10 +1373,15 @@ var fetch2 = {
1387
1373
  }
1388
1374
  if (param.fileName) {
1389
1375
  includeFS = true;
1390
- push(`formData.append('${param.name}', fs.createReadStream('${param.fileName}'));`);
1376
+ push(
1377
+ `formData.append('${param.name}', await new Response(fs.createReadStream('${param.fileName}')).blob());`
1378
+ );
1391
1379
  }
1392
1380
  });
1381
+ reqOpts.body = "formData";
1382
+ blank();
1393
1383
  break;
1384
+ }
1394
1385
  default:
1395
1386
  if (postData.text) {
1396
1387
  reqOpts.body = postData.text;
@@ -1405,12 +1396,11 @@ var fetch2 = {
1405
1396
  reqOpts.headers.cookie = cookiesString;
1406
1397
  }
1407
1398
  }
1408
- blank();
1409
1399
  push(`const url = '${url}';`);
1410
1400
  if (reqOpts.headers && !Object.keys(reqOpts.headers).length) {
1411
1401
  delete reqOpts.headers;
1412
1402
  }
1413
- const stringifiedOptions = stringifyObject9(reqOpts, {
1403
+ const stringifiedOptions = stringifyObject7(reqOpts, {
1414
1404
  indent: " ",
1415
1405
  inlineCharacterLimit: 80,
1416
1406
  // The Fetch API body only accepts string parameters, but stringified JSON can be difficult to
@@ -1426,17 +1416,13 @@ var fetch2 = {
1426
1416
  push(`const options = ${stringifiedOptions};`);
1427
1417
  blank();
1428
1418
  if (includeFS) {
1429
- unshift("const fs = require('fs');");
1430
- }
1431
- if (postData.params && postData.mimeType === "multipart/form-data") {
1432
- push("options.body = formData;");
1433
- blank();
1419
+ unshift("import fs from 'fs';\n");
1434
1420
  }
1435
1421
  push("fetch(url, options)");
1436
1422
  push(".then(res => res.json())", 1);
1437
1423
  push(".then(json => console.log(json))", 1);
1438
- push(".catch(err => console.error('error:' + err));", 1);
1439
- return join().replace(/'encodedParams'/, "encodedParams").replace(/"fs\.createReadStream\(\\"(.+)\\"\)"/, 'fs.createReadStream("$1")');
1424
+ push(".catch(err => console.error(err));", 1);
1425
+ return join().replace(/'encodedParams'/, "encodedParams").replace(/'formData'/, "formData");
1440
1426
  }
1441
1427
  };
1442
1428
  var native3 = {
@@ -1459,7 +1445,7 @@ var native3 = {
1459
1445
  };
1460
1446
  push(`const http = require('${uriObj.protocol?.replace(":", "")}');`);
1461
1447
  blank();
1462
- push(`const options = ${stringifyObject9(reqOpts, { indent })};`);
1448
+ push(`const options = ${stringifyObject7(reqOpts, { indent })};`);
1463
1449
  blank();
1464
1450
  push("const req = http.request(options, function (res) {");
1465
1451
  push("const chunks = [];", 1);
@@ -1479,7 +1465,7 @@ var native3 = {
1479
1465
  if (postData.paramsObj) {
1480
1466
  unshift("const qs = require('querystring');");
1481
1467
  push(
1482
- `req.write(qs.stringify(${stringifyObject9(postData.paramsObj, {
1468
+ `req.write(qs.stringify(${stringifyObject7(postData.paramsObj, {
1483
1469
  indent: " ",
1484
1470
  inlineCharacterLimit: 80
1485
1471
  })}));`
@@ -1489,7 +1475,7 @@ var native3 = {
1489
1475
  case "application/json":
1490
1476
  if (postData.jsonObj) {
1491
1477
  push(
1492
- `req.write(JSON.stringify(${stringifyObject9(postData.jsonObj, {
1478
+ `req.write(JSON.stringify(${stringifyObject7(postData.jsonObj, {
1493
1479
  indent: " ",
1494
1480
  inlineCharacterLimit: 80
1495
1481
  })}));`
@@ -1498,208 +1484,24 @@ var native3 = {
1498
1484
  break;
1499
1485
  default:
1500
1486
  if (postData.text) {
1501
- push(`req.write(${stringifyObject9(postData.text, { indent })});`);
1487
+ push(`req.write(${stringifyObject7(postData.text, { indent })});`);
1502
1488
  }
1503
1489
  }
1504
1490
  push("req.end();");
1505
1491
  return join();
1506
1492
  }
1507
1493
  };
1508
- var request = {
1509
- info: {
1510
- key: "request",
1511
- title: "Request",
1512
- link: "https://github.com/request/request",
1513
- description: "Simplified HTTP request client",
1514
- extname: ".cjs",
1515
- installation: "npm install request --save"
1516
- },
1517
- convert: ({ method, url, fullUrl, postData, headersObj, cookies }, options) => {
1518
- const opts = {
1519
- indent: " ",
1520
- ...options
1521
- };
1522
- let includeFS = false;
1523
- const { push, blank, join, unshift, addPostProcessor } = new CodeBuilder({ indent: opts.indent });
1524
- push("const request = require('request');");
1525
- blank();
1526
- const reqOpts = {
1527
- method,
1528
- url: fullUrl
1529
- };
1530
- if (Object.keys(headersObj).length) {
1531
- reqOpts.headers = headersObj;
1532
- }
1533
- switch (postData.mimeType) {
1534
- case "application/x-www-form-urlencoded":
1535
- reqOpts.form = postData.paramsObj;
1536
- break;
1537
- case "application/json":
1538
- if (postData.jsonObj) {
1539
- reqOpts.body = postData.jsonObj;
1540
- reqOpts.json = true;
1541
- }
1542
- break;
1543
- case "multipart/form-data":
1544
- if (!postData.params) {
1545
- break;
1546
- }
1547
- reqOpts.formData = {};
1548
- postData.params.forEach((param) => {
1549
- if (!param.fileName && !param.fileName && !param.contentType) {
1550
- reqOpts.formData[param.name] = param.value;
1551
- return;
1552
- }
1553
- let attachment = {};
1554
- if (param.fileName) {
1555
- includeFS = true;
1556
- attachment = {
1557
- value: `fs.createReadStream(${param.fileName})`,
1558
- options: {
1559
- filename: param.fileName,
1560
- contentType: param.contentType ? param.contentType : null
1561
- }
1562
- };
1563
- } else if (param.value) {
1564
- attachment.value = param.value;
1565
- }
1566
- reqOpts.formData[param.name] = attachment;
1567
- });
1568
- addPostProcessor((code) => code.replace(/'fs\.createReadStream\((.*)\)'/, "fs.createReadStream('$1')"));
1569
- break;
1570
- default:
1571
- if (postData.text) {
1572
- reqOpts.body = postData.text;
1573
- }
1574
- }
1575
- if (cookies.length) {
1576
- reqOpts.jar = "JAR";
1577
- push("const jar = request.jar();");
1578
- cookies.forEach(({ name, value }) => {
1579
- push(`jar.setCookie(request.cookie('${encodeURIComponent(name)}=${encodeURIComponent(value)}'), '${url}');`);
1580
- });
1581
- blank();
1582
- addPostProcessor((code) => code.replace(/'JAR'/, "jar"));
1583
- }
1584
- if (includeFS) {
1585
- unshift("const fs = require('fs');");
1586
- }
1587
- push(`const options = ${stringifyObject9(reqOpts, { indent: " ", inlineCharacterLimit: 80 })};`);
1588
- blank();
1589
- push("request(options, function (error, response, body) {");
1590
- push("if (error) throw new Error(error);", 1);
1591
- blank();
1592
- push("console.log(body);", 1);
1593
- push("});");
1594
- return join();
1595
- }
1596
- };
1597
- var unirest2 = {
1598
- info: {
1599
- key: "unirest",
1600
- title: "Unirest",
1601
- link: "http://unirest.io/nodejs.html",
1602
- description: "Lightweight HTTP Request Client Library",
1603
- extname: ".cjs"
1604
- },
1605
- convert: ({ method, url, cookies, queryObj, postData, headersObj }, options) => {
1606
- const opts = {
1607
- indent: " ",
1608
- ...options
1609
- };
1610
- let includeFS = false;
1611
- const { addPostProcessor, blank, join, push, unshift } = new CodeBuilder({
1612
- indent: opts.indent
1613
- });
1614
- push("const unirest = require('unirest');");
1615
- blank();
1616
- push(`const req = unirest('${method}', '${url}');`);
1617
- blank();
1618
- if (cookies.length) {
1619
- push("const CookieJar = unirest.jar();");
1620
- cookies.forEach((cookie) => {
1621
- push(`CookieJar.add('${encodeURIComponent(cookie.name)}=${encodeURIComponent(cookie.value)}', '${url}');`);
1622
- });
1623
- push("req.jar(CookieJar);");
1624
- blank();
1625
- }
1626
- if (Object.keys(queryObj).length) {
1627
- push(`req.query(${stringifyObject9(queryObj, { indent: opts.indent })});`);
1628
- blank();
1629
- }
1630
- if (Object.keys(headersObj).length) {
1631
- push(`req.headers(${stringifyObject9(headersObj, { indent: opts.indent })});`);
1632
- blank();
1633
- }
1634
- switch (postData.mimeType) {
1635
- case "application/x-www-form-urlencoded":
1636
- if (postData.paramsObj) {
1637
- push(`req.form(${stringifyObject9(postData.paramsObj, { indent: opts.indent })});`);
1638
- blank();
1639
- }
1640
- break;
1641
- case "application/json":
1642
- if (postData.jsonObj) {
1643
- push("req.type('json');");
1644
- push(`req.send(${stringifyObject9(postData.jsonObj, { indent: opts.indent })});`);
1645
- blank();
1646
- }
1647
- break;
1648
- case "multipart/form-data": {
1649
- if (!postData.params) {
1650
- break;
1651
- }
1652
- const multipart = [];
1653
- postData.params.forEach((param) => {
1654
- const part = {};
1655
- if (param.fileName && !param.value) {
1656
- includeFS = true;
1657
- part.body = `fs.createReadStream('${param.fileName}')`;
1658
- addPostProcessor((code) => code.replace(/'fs\.createReadStream\(\\'(.+)\\'\)'/, "fs.createReadStream('$1')"));
1659
- } else if (param.value) {
1660
- part.body = param.value;
1661
- }
1662
- if (part.body) {
1663
- if (param.contentType) {
1664
- part["content-type"] = param.contentType;
1665
- }
1666
- multipart.push(part);
1667
- }
1668
- });
1669
- push(`req.multipart(${stringifyObject9(multipart, { indent: opts.indent })});`);
1670
- blank();
1671
- break;
1672
- }
1673
- default:
1674
- if (postData.text) {
1675
- push(`req.send(${stringifyObject9(postData.text, { indent: opts.indent })});`);
1676
- blank();
1677
- }
1678
- }
1679
- if (includeFS) {
1680
- unshift("const fs = require('fs');");
1681
- }
1682
- push("req.end(function (res) {");
1683
- push("if (res.error) throw new Error(res.error);", 1);
1684
- blank();
1685
- push("console.log(res.body);", 1);
1686
- push("});");
1687
- return join();
1688
- }
1689
- };
1690
1494
 
1691
1495
  // src/targets/node/target.ts
1692
1496
  var node = {
1693
1497
  info: {
1694
1498
  key: "node",
1695
1499
  title: "Node.js",
1696
- default: "native",
1500
+ default: "fetch",
1697
1501
  cli: "node %s"
1698
1502
  },
1699
1503
  clientsById: {
1700
1504
  native: native3,
1701
- request,
1702
- unirest: unirest2,
1703
1505
  axios: axios2,
1704
1506
  fetch: fetch2
1705
1507
  }
@@ -1877,7 +1679,7 @@ var cohttp = {
1877
1679
  link: "https://github.com/mirage/ocaml-cohttp",
1878
1680
  description: "Cohttp is a very lightweight HTTP server using Lwt or Async for OCaml",
1879
1681
  extname: ".ml",
1880
- installation: "opam install cohttp-lwt-unix cohttp-async"
1682
+ installation: () => "opam install cohttp-lwt-unix cohttp-async"
1881
1683
  },
1882
1684
  convert: ({ fullUrl, allHeaders, postData, method }, options) => {
1883
1685
  const opts = {
@@ -2124,7 +1926,7 @@ var guzzle = {
2124
1926
  link: "http://docs.guzzlephp.org/en/stable/",
2125
1927
  description: "PHP with Guzzle",
2126
1928
  extname: ".php",
2127
- installation: "composer require guzzlehttp/guzzle"
1929
+ installation: () => "composer require guzzlehttp/guzzle"
2128
1930
  },
2129
1931
  convert: ({ postData, fullUrl, method, cookies, headersObj }, options) => {
2130
1932
  const opts = {
@@ -2185,9 +1987,7 @@ var guzzle = {
2185
1987
  requestPush(`'body' => ${convertType(postData.text)},`, 1);
2186
1988
  }
2187
1989
  }
2188
- const headers = Object.keys(headersObj).sort().map(function(key) {
2189
- return `${opts.indent}${opts.indent}'${key}' => '${escapeForSingleQuotes(headersObj[key])}',`;
2190
- });
1990
+ const headers = Object.keys(headersObj).sort().map((key) => `${opts.indent}${opts.indent}'${key}' => '${escapeForSingleQuotes(headersObj[key])}',`);
2191
1991
  const cookieString = cookies.map((cookie) => `${encodeURIComponent(cookie.name)}=${encodeURIComponent(cookie.value)}`).join("; ");
2192
1992
  if (cookieString.length) {
2193
1993
  headers.push(`${opts.indent}${opts.indent}'cookie' => '${escapeForSingleQuotes(cookieString)}',`);
@@ -2550,7 +2350,7 @@ var requests = {
2550
2350
  link: "http://docs.python-requests.org/en/latest/api/#requests.request",
2551
2351
  description: "Requests HTTP library",
2552
2352
  extname: ".py",
2553
- installation: "python -m pip install requests"
2353
+ installation: () => "python -m pip install requests"
2554
2354
  },
2555
2355
  convert: ({ fullUrl, postData, allHeaders, method }, options) => {
2556
2356
  const opts = {
@@ -2650,22 +2450,22 @@ var requests = {
2650
2450
  push("}");
2651
2451
  blank();
2652
2452
  }
2653
- let request2 = builtInMethods.includes(method) ? `response = requests.${method.toLowerCase()}(url` : `response = requests.request("${method}", url`;
2453
+ let request = builtInMethods.includes(method) ? `response = requests.${method.toLowerCase()}(url` : `response = requests.request("${method}", url`;
2654
2454
  if (hasPayload) {
2655
2455
  if (jsonPayload) {
2656
- request2 += ", json=payload";
2456
+ request += ", json=payload";
2657
2457
  } else {
2658
- request2 += ", data=payload";
2458
+ request += ", data=payload";
2659
2459
  }
2660
2460
  }
2661
2461
  if (hasFiles) {
2662
- request2 += ", files=files";
2462
+ request += ", files=files";
2663
2463
  }
2664
2464
  if (headerCount > 0) {
2665
- request2 += ", headers=headers";
2465
+ request += ", headers=headers";
2666
2466
  }
2667
- request2 += ")";
2668
- push(request2);
2467
+ request += ")";
2468
+ push(request);
2669
2469
  blank();
2670
2470
  push("print(response.text)");
2671
2471
  return join();
@@ -2750,22 +2550,22 @@ var httr = {
2750
2550
  const setContentType = `content_type("${escapeForDoubleQuotes(postData.mimeType)}")`;
2751
2551
  const otherHeaders = Object.entries(allHeaders).filter(([key]) => !["cookie", "accept", "content-type"].includes(key.toLowerCase())).map(([key, value]) => `'${key}' = '${escapeForSingleQuotes(value)}'`).join(", ");
2752
2552
  const setHeaders = otherHeaders ? `add_headers(${otherHeaders})` : void 0;
2753
- let request2 = `response <- VERB("${method}", url`;
2553
+ let request = `response <- VERB("${method}", url`;
2754
2554
  if (payload) {
2755
- request2 += ", body = payload";
2555
+ request += ", body = payload";
2756
2556
  }
2757
2557
  if (queryString.length) {
2758
- request2 += ", query = queryString";
2558
+ request += ", query = queryString";
2759
2559
  }
2760
2560
  const headerAdditions = [setHeaders, setContentType, setAccept, setCookies].filter((x) => !!x).join(", ");
2761
2561
  if (headerAdditions) {
2762
- request2 += `, ${headerAdditions}`;
2562
+ request += `, ${headerAdditions}`;
2763
2563
  }
2764
2564
  if (postData.text || postData.jsonObj || postData.params) {
2765
- request2 += ", encode = encode";
2565
+ request += ", encode = encode";
2766
2566
  }
2767
- request2 += ")";
2768
- push(request2);
2567
+ request += ")";
2568
+ push(request);
2769
2569
  blank();
2770
2570
  push('content(response, "text")');
2771
2571
  return join();
@@ -2954,18 +2754,16 @@ ${indent}` : " "
2954
2754
  case "application/x-www-form-urlencoded":
2955
2755
  if (postData.params) {
2956
2756
  postData.params.forEach((param) => {
2957
- const unencoded = param.name;
2958
2757
  const encoded = encodeURIComponent(param.name);
2959
- const needsEncoding = encoded !== unencoded;
2960
- const name = needsEncoding ? encoded : unencoded;
2961
- const flag = binary ? "--data-binary" : needsEncoding ? "--data-urlencode" : arg("data");
2758
+ const name = encoded !== param.name ? encoded : param.name;
2759
+ const flag = binary ? "--data-binary" : "--data-urlencode";
2962
2760
  push(`${flag} ${quote(`${name}=${param.value}`)}`);
2963
2761
  });
2964
2762
  } else {
2965
2763
  push(`${binary ? "--data-binary" : arg("data")} ${quote(postData.text)}`);
2966
2764
  }
2967
2765
  break;
2968
- default:
2766
+ default: {
2969
2767
  if (!postData.text) {
2970
2768
  break;
2971
2769
  }
@@ -2992,13 +2790,14 @@ ${JSON.stringify(jsonPayload, null, indentJSON)}
2992
2790
  '`
2993
2791
  );
2994
2792
  }
2995
- } catch (err) {
2793
+ } catch {
2996
2794
  }
2997
2795
  }
2998
2796
  }
2999
2797
  if (!builtPayload) {
3000
2798
  push(`${binary ? "--data-binary" : arg("data")} ${quote(postData.text)}`);
3001
2799
  }
2800
+ }
3002
2801
  }
3003
2802
  return join();
3004
2803
  }
@@ -3012,7 +2811,7 @@ var httpie = {
3012
2811
  link: "http://httpie.org/",
3013
2812
  description: "a CLI, cURL-like tool for humans",
3014
2813
  extname: ".sh",
3015
- installation: "brew install httpie"
2814
+ installation: () => "brew install httpie"
3016
2815
  },
3017
2816
  convert: ({ allHeaders, postData, queryObj, fullUrl, method, url }, options) => {
3018
2817
  const opts = {
@@ -3081,7 +2880,7 @@ ${opts.indent}` : " "
3081
2880
  push(`${key}:${quote(allHeaders[key])}`);
3082
2881
  });
3083
2882
  if (postData.mimeType === "application/x-www-form-urlencoded") {
3084
- if (postData.params && postData.params.length) {
2883
+ if (postData.params?.length) {
3085
2884
  flags.push(opts.short ? "-f" : "--form");
3086
2885
  postData.params.forEach((param) => {
3087
2886
  push(`${param.name}=${quote(param.value)}`);
@@ -3237,7 +3036,9 @@ var urlsession = {
3237
3036
  const parameters = postData.params.map((p) => `"${p.name}": "${p.value}"`);
3238
3037
  if (opts.pretty) {
3239
3038
  push("let parameters = [");
3240
- parameters.forEach((param) => push(`${param},`, 1));
3039
+ parameters.forEach((param) => {
3040
+ push(`${param},`, 1);
3041
+ });
3241
3042
  push("]");
3242
3043
  } else {
3243
3044
  push(`let parameters = [${parameters.join(", ")}]`);
@@ -3451,5 +3252,5 @@ var addTargetClient = (targetId, client) => {
3451
3252
  };
3452
3253
 
3453
3254
  export { addClientPlugin, addTarget, addTargetClient, getHeaderName, isClient, isTarget, targets };
3454
- //# sourceMappingURL=chunk-532RKFLR.js.map
3455
- //# sourceMappingURL=chunk-532RKFLR.js.map
3255
+ //# sourceMappingURL=chunk-EFUQ6POB.js.map
3256
+ //# sourceMappingURL=chunk-EFUQ6POB.js.map