@readme/httpsnippet 8.1.4 → 9.0.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.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2023 ReadMe (https://readme.com)
3
+ Copyright (c) 2024 ReadMe (https://readme.com)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -25,7 +25,7 @@ _Required_ Type: `object`
25
25
  The [HAR](http://www.softwareishard.com/blog/har-12-spec/#request) request object to generate a snippet for.
26
26
 
27
27
  ```ts
28
- import { HTTPSnippet } from 'httpsnippet';
28
+ import { HTTPSnippet } from '@readme/httpsnippet';
29
29
 
30
30
  const snippet = new HTTPSnippet({
31
31
  method: 'GET',
@@ -56,7 +56,7 @@ Type: `object`
56
56
  Target options, _see [wiki](https://github.com/Kong/httpsnippet/wiki/Targets) for details_
57
57
 
58
58
  ```ts
59
- import { HTTPSnippet } from 'httpsnippet';
59
+ import { HTTPSnippet } from '@readme/httpsnippet';
60
60
 
61
61
  const snippet = new HTTPSnippet({
62
62
  method: 'GET',
@@ -64,11 +64,11 @@ const snippet = new HTTPSnippet({
64
64
  });
65
65
 
66
66
  // generate Node.js: Native output
67
- console.log(await snippet.convert('node'));
67
+ console.log(snippet.convert('node'));
68
68
 
69
69
  // generate Node.js: Native output, indent with tabs
70
70
  console.log(
71
- await snippet.convert('node', {
71
+ snippet.convert('node', {
72
72
  indent: '\t',
73
73
  }),
74
74
  );
@@ -95,7 +95,7 @@ Type: `object`
95
95
  Target options, _see [wiki](https://github.com/Kong/httpsnippet/wiki/Targets) for details_
96
96
 
97
97
  ```ts
98
- import { HTTPSnippet } from 'httpsnippet';
98
+ import { HTTPSnippet } from '@readme/httpsnippet';
99
99
 
100
100
  const snippet = new HTTPSnippet({
101
101
  method: 'GET',
@@ -104,13 +104,13 @@ const snippet = new HTTPSnippet({
104
104
 
105
105
  // generate Shell: cURL output
106
106
  console.log(
107
- await snippet.convert('shell', 'curl', {
107
+ snippet.convert('shell', 'curl', {
108
108
  indent: '\t',
109
109
  }),
110
110
  );
111
111
 
112
112
  // generate Node.js: Unirest output
113
- console.log(await snippet.convert('node', 'unirest'));
113
+ console.log(snippet.convert('node', 'unirest'));
114
114
  ```
115
115
 
116
116
  ### addTarget(target)
@@ -2948,11 +2948,11 @@ ${indent}` : " "
2948
2948
  postData.params?.forEach((param) => {
2949
2949
  let post = "";
2950
2950
  if (param.fileName) {
2951
- post = `${param.name}=@${param.fileName}`;
2951
+ post = `${param.name}='@${param.fileName}'`;
2952
2952
  } else {
2953
- post = `${param.name}=${param.value}`;
2953
+ post = quote(`${param.name}=${param.value}`);
2954
2954
  }
2955
- push(`${arg("form")} ${quote(post)}`);
2955
+ push(`${arg("form")} ${post}`);
2956
2956
  });
2957
2957
  break;
2958
2958
  case "application/x-www-form-urlencoded":
@@ -2962,7 +2962,7 @@ ${indent}` : " "
2962
2962
  const encoded = encodeURIComponent(param.name);
2963
2963
  const needsEncoding = encoded !== unencoded;
2964
2964
  const name = needsEncoding ? encoded : unencoded;
2965
- const flag = binary ? "--data-binary" : `--data${needsEncoding ? "-urlencode" : ""}`;
2965
+ const flag = binary ? "--data-binary" : needsEncoding ? "--data-urlencode" : arg("data");
2966
2966
  push(`${flag} ${quote(`${name}=${param.value}`)}`);
2967
2967
  });
2968
2968
  } else {
@@ -3452,4 +3452,4 @@ var addTargetClient = (targetId, client) => {
3452
3452
 
3453
3453
  export { addClientPlugin, addTarget, addTargetClient, getHeaderName, isClient, isTarget, targets };
3454
3454
  //# sourceMappingURL=out.js.map
3455
- //# sourceMappingURL=chunk-ENNB4GTT.js.map
3455
+ //# sourceMappingURL=chunk-R65NNSSK.js.map