Socket
Socket
Sign inDemoInstall

httpsnippet-lite

Package Overview
Dependencies
9
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.2 to 3.0.3

2

dist/cjs/helpers/code-builder.js

@@ -59,5 +59,5 @@ "use strict";

this.indentationCharacter = indent || DEFAULT_INDENTATION_CHARACTER;
this.lineJoin = join ?? DEFAULT_LINE_JOIN;
this.lineJoin = join !== null && join !== void 0 ? join : DEFAULT_LINE_JOIN;
}
}
exports.CodeBuilder = CodeBuilder;

@@ -10,3 +10,3 @@ "use strict";

exports.availableTargets = availableTargets;
const extname = (targetId) => targets_js_1.targets[targetId]?.info.extname || '';
const extname = (targetId) => { var _a; return ((_a = targets_js_1.targets[targetId]) === null || _a === void 0 ? void 0 : _a.info.extname) || ''; };
exports.extname = extname;

@@ -46,2 +46,3 @@ "use strict";

this.requests = Promise.all(entries.map(({ request }) => {
var _a;
// add optional properties to make validation successful

@@ -56,3 +57,3 @@ const req = {

postData: {
mimeType: request.postData?.mimeType || 'application/octet-stream',
mimeType: ((_a = request.postData) === null || _a === void 0 ? void 0 : _a.mimeType) || 'application/octet-stream',
},

@@ -65,2 +66,3 @@ ...request,

async prepare(harRequest) {
var _a, _b, _c, _d;
const request = {

@@ -99,7 +101,7 @@ ...harRequest,

// construct Cookie header
const cookies = request.cookies?.map(({ name, value }) => `${encodeURIComponent(name)}=${encodeURIComponent(value)}`);
if (cookies?.length) {
const cookies = (_a = request.cookies) === null || _a === void 0 ? void 0 : _a.map(({ name, value }) => `${encodeURIComponent(name)}=${encodeURIComponent(value)}`);
if (cookies === null || cookies === void 0 ? void 0 : cookies.length) {
request.allHeaders.cookie = cookies.join('; ');
}
switch (request.postData?.mimeType) {
switch ((_b = request.postData) === null || _b === void 0 ? void 0 : _b.mimeType) {
case 'multipart/mixed':

@@ -112,3 +114,3 @@ case 'multipart/related':

request.postData.mimeType = 'multipart/form-data';
if (request.postData?.params) {
if ((_c = request.postData) === null || _c === void 0 ? void 0 : _c.params) {
const form = new formdata_node_1.FormData();

@@ -119,3 +121,3 @@ // TODO: THIS ABSOLUTELY MUST BE REMOVED.

const boundary = '---011000010111000001101001'; // this is binary for "api". yep.
request.postData?.params.forEach(param => {
(_d = request.postData) === null || _d === void 0 ? void 0 : _d.params.forEach(param => {
const name = param.name;

@@ -122,0 +124,0 @@ const value = param.value || '';

@@ -35,3 +35,3 @@ "use strict";

}
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
blank();

@@ -38,0 +38,0 @@ push(`curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, ${JSON.stringify(postData.text)});`);

@@ -97,3 +97,3 @@ "use strict";

convert: ({ queryObj, method, postData, url, allHeaders }, options) => {
const { push, join } = new code_builder_js_1.CodeBuilder({ indent: options?.indent });
const { push, join } = new code_builder_js_1.CodeBuilder({ indent: options === null || options === void 0 ? void 0 : options.indent });
const methods = ['get', 'post', 'put', 'delete', 'patch', 'head', 'options'];

@@ -109,3 +109,3 @@ method = method.toLowerCase();

};
switch (postData?.mimeType) {
switch (postData === null || postData === void 0 ? void 0 : postData.mimeType) {
case 'application/json':

@@ -112,0 +112,0 @@ {

@@ -41,2 +41,3 @@ "use strict";

convert: ({ allHeaders, postData, method, fullUrl }, options) => {
var _a, _b;
const opts = {

@@ -99,3 +100,3 @@ indent: ' ',

}
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
const contentType = postData.mimeType;

@@ -106,3 +107,3 @@ switch (contentType) {

push('{', 1);
postData.params?.forEach(param => {
(_a = postData.params) === null || _a === void 0 ? void 0 : _a.forEach(param => {
push(`{ "${param.name}", "${param.value}" },`, 2);

@@ -115,3 +116,3 @@ });

push('{', 1);
postData.params?.forEach(param => {
(_b = postData.params) === null || _b === void 0 ? void 0 : _b.forEach(param => {
push(`new StringContent(${JSON.stringify(param.value || '')})`, 2);

@@ -137,3 +138,3 @@ push('{', 2);

default:
push(`Content = new StringContent(${JSON.stringify(postData?.text || '')})`, 1);
push(`Content = new StringContent(${JSON.stringify((postData === null || postData === void 0 ? void 0 : postData.text) || '')})`, 1);
push('{', 1);

@@ -140,0 +141,0 @@ push('Headers =', 2);

@@ -26,6 +26,6 @@ "use strict";

});
cookies?.forEach(({ name, value }) => {
cookies === null || cookies === void 0 ? void 0 : cookies.forEach(({ name, value }) => {
push(`request.AddCookie("${name}", "${value}");`);
});
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
const header = (0, headers_js_1.getHeader)(allHeaders, 'content-type');

@@ -32,0 +32,0 @@ const text = JSON.stringify(postData.text);

@@ -46,3 +46,3 @@ "use strict";

}
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
push('"strings"', indent);

@@ -82,3 +82,3 @@ }

// If we have body content or not create the var and reader or nil
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
push(`payload := strings.NewReader(${JSON.stringify(postData.text)})`, indent);

@@ -85,0 +85,0 @@ blank();

@@ -58,3 +58,3 @@ "use strict";

// Automatically set Content-Length header if option is on, postData is present and no header already exists.
if (opts.autoContentLength && postData?.text && !headerKeys.includes('content-length')) {
if (opts.autoContentLength && (postData === null || postData === void 0 ? void 0 : postData.text) && !headerKeys.includes('content-length')) {
push(`Content-Length: ${postData.text.length}`);

@@ -67,3 +67,3 @@ }

// RFC 7230 Section 3.3. Message Body
const messageBody = postData?.text || '';
const messageBody = (postData === null || postData === void 0 ? void 0 : postData.text) || '';
// RFC 7230 Section 3. Message Format

@@ -70,0 +70,0 @@ // Extra CRLF separating the headers from the body.

@@ -34,3 +34,3 @@ "use strict";

});
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
push(`.setBody(${JSON.stringify(postData.text)})`, 1);

@@ -37,0 +37,0 @@ }

@@ -33,3 +33,3 @@ "use strict";

});
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
push(`.method("${method.toUpperCase()}", HttpRequest.BodyPublishers.ofString(${JSON.stringify(postData.text)}))`, 2);

@@ -36,0 +36,0 @@ }

@@ -32,3 +32,3 @@ "use strict";

blank();
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
if (postData.boundary) {

@@ -45,3 +45,3 @@ push(`MediaType mediaType = MediaType.parse("${postData.mimeType}; boundary=${postData.boundary}");`);

if (!methods.includes(method.toUpperCase())) {
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
push(`.method("${method.toUpperCase()}", body)`, 1);

@@ -54,3 +54,3 @@ }

else if (methodsWithBody.includes(method.toUpperCase())) {
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
push(`.${method.toLowerCase()}(body)`, 1);

@@ -57,0 +57,0 @@ }

@@ -39,3 +39,3 @@ "use strict";

});
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
push(`.body(${JSON.stringify(postData.text)})`, 1);

@@ -42,0 +42,0 @@ }

@@ -43,3 +43,3 @@ "use strict";

}
switch (postData?.mimeType) {
switch (postData === null || postData === void 0 ? void 0 : postData.mimeType) {
case 'application/x-www-form-urlencoded':

@@ -73,3 +73,3 @@ if (postData.params) {

default:
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
requestOptions.data = postData.text;

@@ -76,0 +76,0 @@ }

@@ -43,3 +43,3 @@ "use strict";

push(`const url = '${fullUrl}';`);
switch (postData?.mimeType) {
switch (postData === null || postData === void 0 ? void 0 : postData.mimeType) {
case 'application/x-www-form-urlencoded':

@@ -68,3 +68,3 @@ options.body = postData.paramsObj ? postData.paramsObj : postData.text;

default:
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
options.body = postData.text;

@@ -90,3 +90,3 @@ }

blank();
if (postData?.params && postData.mimeType === 'multipart/form-data') {
if ((postData === null || postData === void 0 ? void 0 : postData.params) && postData.mimeType === 'multipart/form-data') {
push('options.body = form;');

@@ -93,0 +93,0 @@ blank();

@@ -27,2 +27,3 @@ "use strict";

convert: ({ fullUrl, method, allHeaders, postData }, options) => {
var _a;
const opts = {

@@ -40,3 +41,3 @@ indent: ' ',

};
switch (postData?.mimeType) {
switch (postData === null || postData === void 0 ? void 0 : postData.mimeType) {
case 'application/x-www-form-urlencoded':

@@ -63,3 +64,3 @@ settings.data = postData.paramsObj ? postData.paramsObj : postData.text;

if ((0, headers_js_1.hasHeader)(allHeaders, 'content-type')) {
if ((0, headers_js_1.getHeader)(allHeaders, 'content-type')?.includes('boundary')) {
if ((_a = (0, headers_js_1.getHeader)(allHeaders, 'content-type')) === null || _a === void 0 ? void 0 : _a.includes('boundary')) {
const headerName = (0, headers_js_1.getHeaderName)(allHeaders, 'content-type');

@@ -74,3 +75,3 @@ if (headerName) {

default:
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
settings.data = postData.text;

@@ -77,0 +78,0 @@ }

@@ -28,2 +28,3 @@ "use strict";

convert: ({ postData, allHeaders, method, fullUrl }, options) => {
var _a;
const opts = {

@@ -35,3 +36,3 @@ indent: ' ',

const { blank, push, join } = new code_builder_js_1.CodeBuilder({ indent: opts.indent });
switch (postData?.mimeType) {
switch (postData === null || postData === void 0 ? void 0 : postData.mimeType) {
case 'application/json':

@@ -53,3 +54,3 @@ push(`const data = JSON.stringify(${(0, stringify_object_1.default)(postData.jsonObj, {

if ((0, headers_js_1.hasHeader)(allHeaders, 'content-type')) {
if ((0, headers_js_1.getHeader)(allHeaders, 'content-type')?.includes('boundary')) {
if ((_a = (0, headers_js_1.getHeader)(allHeaders, 'content-type')) === null || _a === void 0 ? void 0 : _a.includes('boundary')) {
const headerName = (0, headers_js_1.getHeaderName)(allHeaders, 'content-type');

@@ -64,3 +65,3 @@ if (headerName) {

default:
push(`const data = ${postData?.text ? `'${postData.text}'` : 'null'};`);
push(`const data = ${(postData === null || postData === void 0 ? void 0 : postData.text) ? `'${postData.text}'` : 'null'};`);
blank();

@@ -67,0 +68,0 @@ }

@@ -32,3 +32,3 @@ "use strict";

blank();
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
if (postData.boundary) {

@@ -45,3 +45,3 @@ push(`val mediaType = MediaType.parse("${postData.mimeType}; boundary=${postData.boundary}")`);

if (!methods.includes(method.toUpperCase())) {
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
push(`.method("${method.toUpperCase()}", body)`, 1);

@@ -54,3 +54,3 @@ }

else if (methodsWithBody.includes(method.toUpperCase())) {
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
push(`.${method.toLowerCase()}(body)`, 1);

@@ -57,0 +57,0 @@ }

@@ -42,3 +42,3 @@ "use strict";

}
switch (postData?.mimeType) {
switch (postData === null || postData === void 0 ? void 0 : postData.mimeType) {
case 'application/x-www-form-urlencoded':

@@ -65,3 +65,3 @@ if (postData.params) {

blank();
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
reqOpts.data = postData.text;

@@ -68,0 +68,0 @@ }

@@ -27,2 +27,3 @@ "use strict";

convert: ({ method, fullUrl, postData, headersObj, cookies }, options) => {
var _a;
const opts = {

@@ -42,7 +43,7 @@ indent: ' ',

}
switch (postData?.mimeType) {
switch (postData === null || postData === void 0 ? void 0 : postData.mimeType) {
case 'application/x-www-form-urlencoded':
unshift("const { URLSearchParams } = require('url');");
push('const encodedParams = new URLSearchParams();');
postData.params?.forEach(param => {
(_a = postData.params) === null || _a === void 0 ? void 0 : _a.forEach(param => {
push(`encodedParams.set('${param.name}', '${param.value}');`);

@@ -83,3 +84,3 @@ });

default:
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
reqOpts.body = postData.text;

@@ -111,3 +112,3 @@ }

}
if (postData?.params && postData.mimeType === 'multipart/form-data') {
if ((postData === null || postData === void 0 ? void 0 : postData.params) && postData.mimeType === 'multipart/form-data') {
push('options.body = formData;');

@@ -114,0 +115,0 @@ }

@@ -53,3 +53,3 @@ "use strict";

blank();
switch (postData?.mimeType) {
switch (postData === null || postData === void 0 ? void 0 : postData.mimeType) {
case 'application/x-www-form-urlencoded':

@@ -73,3 +73,3 @@ if (postData.paramsObj) {

default:
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
push(`req.write(${(0, stringify_object_1.default)(postData.text, { indent })});`);

@@ -76,0 +76,0 @@ }

@@ -44,3 +44,3 @@ "use strict";

}
switch (postData?.mimeType) {
switch (postData === null || postData === void 0 ? void 0 : postData.mimeType) {
case 'application/x-www-form-urlencoded':

@@ -83,3 +83,3 @@ reqOpts.form = postData.paramsObj;

default:
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
reqOpts.body = postData.text;

@@ -86,0 +86,0 @@ }

@@ -54,3 +54,3 @@ "use strict";

}
switch (postData?.mimeType) {
switch (postData === null || postData === void 0 ? void 0 : postData.mimeType) {
case 'application/x-www-form-urlencoded':

@@ -96,3 +96,3 @@ if (postData.paramsObj) {

default:
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
push(`req.send(${(0, stringify_object_1.default)(postData.text, { indent: opts.indent })});`);

@@ -99,0 +99,0 @@ blank();

@@ -23,2 +23,3 @@ "use strict";

convert: ({ allHeaders, postData, method, fullUrl }, options) => {
var _a;
const opts = {

@@ -47,3 +48,3 @@ indent: ' ',

case 'application/x-www-form-urlencoded':
if (postData.params?.length) {
if ((_a = postData.params) === null || _a === void 0 ? void 0 : _a.length) {
// By appending parameters one by one in the resulting snippet,

@@ -50,0 +51,0 @@ // we make it easier for the user to edit it according to his or her needs after pasting.

@@ -47,3 +47,3 @@ "use strict";

// Add body
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
// Just text

@@ -55,3 +55,3 @@ push(`let body = Cohttp_lwt_body.of_string ${JSON.stringify(postData.text)} in`);

const h = headers.length ? '~headers ' : '';
const b = postData?.text ? '~body ' : '';
const b = (postData === null || postData === void 0 ? void 0 : postData.text) ? '~body ' : '';
const m = methods.includes(method.toLowerCase())

@@ -58,0 +58,0 @@ ? `\`${method.toUpperCase()}`

@@ -74,3 +74,3 @@ "use strict";

{
escape: !postData?.jsonObj,
escape: !(postData === null || postData === void 0 ? void 0 : postData.jsonObj),
name: 'CURLOPT_POSTFIELDS',

@@ -77,0 +77,0 @@ value: postData

@@ -25,2 +25,3 @@ "use strict";

convert: ({ postData, fullUrl, method, cookies, headersObj }, options) => {
var _a;
const opts = {

@@ -39,3 +40,3 @@ closingTag: false,

}
switch (postData?.mimeType) {
switch (postData === null || postData === void 0 ? void 0 : postData.mimeType) {
case 'application/x-www-form-urlencoded':

@@ -71,3 +72,3 @@ requestPush(`'form_params' => ${(0, helpers_js_1.convertType)(postData.paramsObj, opts.indent + opts.indent, opts.indent)},`, 1);

if ((0, headers_js_1.hasHeader)(headersObj, 'content-type')) {
if ((0, headers_js_1.getHeader)(headersObj, 'content-type')?.indexOf('boundary')) {
if ((_a = (0, headers_js_1.getHeader)(headersObj, 'content-type')) === null || _a === void 0 ? void 0 : _a.indexOf('boundary')) {
const headerName = (0, headers_js_1.getHeaderName)(headersObj, 'content-type');

@@ -83,3 +84,3 @@ if (headerName) {

default:
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
requestPush(`'body' => ${(0, helpers_js_1.convertType)(postData.text)},`, 1);

@@ -86,0 +87,0 @@ }

@@ -53,3 +53,3 @@ "use strict";

}
switch (postData?.mimeType) {
switch (postData === null || postData === void 0 ? void 0 : postData.mimeType) {
case 'application/x-www-form-urlencoded':

@@ -66,3 +66,3 @@ push(`$request->setContentType(${(0, helpers_js_1.convertType)(postData.mimeType)});`);

default:
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
push(`$request->setBody(${(0, helpers_js_1.convertType)(postData.text)});`);

@@ -69,0 +69,0 @@ blank();

@@ -24,2 +24,3 @@ "use strict";

convert: ({ postData, headersObj, method, queryObj, cookiesObj, url }, options = {}) => {
var _a;
const { closingTag = false, indent = ' ', noTags = false, shortTags = false } = options;

@@ -35,3 +36,3 @@ const { push, blank, join } = new code_builder_js_1.CodeBuilder({ indent });

blank();
switch (postData?.mimeType) {
switch (postData === null || postData === void 0 ? void 0 : postData.mimeType) {
case 'application/x-www-form-urlencoded':

@@ -69,3 +70,3 @@ push('$body = new http\\Message\\Body;');

if ((0, headers_js_1.hasHeader)(headersObj, 'content-type')) {
if ((0, headers_js_1.getHeader)(headersObj, 'content-type')?.indexOf('boundary')) {
if ((_a = (0, headers_js_1.getHeader)(headersObj, 'content-type')) === null || _a === void 0 ? void 0 : _a.indexOf('boundary')) {
const headerName = (0, headers_js_1.getHeaderName)(headersObj, 'content-type');

@@ -87,3 +88,3 @@ if (headerName) {

default:
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
push('$body = new http\\Message\\Body;');

@@ -90,0 +91,0 @@ push(`$body->append(${(0, helpers_js_1.convertType)(postData.text)});`);

@@ -40,3 +40,3 @@ "use strict";

}
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
commandOptions.push(`-ContentType '${(0, escape_js_1.escapeString)((0, headers_js_1.getHeader)(allHeaders, 'content-type'), {

@@ -43,0 +43,0 @@ delimiter: "'",

@@ -42,3 +42,3 @@ "use strict";

// Create payload string if it exists
const payload = JSON.stringify(postData?.text);
const payload = JSON.stringify(postData === null || postData === void 0 ? void 0 : postData.text);
if (payload) {

@@ -45,0 +45,0 @@ push(`payload = ${payload}`);

@@ -53,3 +53,3 @@ "use strict";

let jsonPayload = false;
switch (postData?.mimeType) {
switch (postData === null || postData === void 0 ? void 0 : postData.mimeType) {
case 'application/json':

@@ -56,0 +56,0 @@ if (postData.jsonObj) {

@@ -24,5 +24,6 @@ "use strict";

convert: ({ url, queryObj, queryString, postData, allHeaders, method }, options = {}) => {
var _a, _b;
// Start snippet
const { push, blank, join } = new code_builder_js_1.CodeBuilder({
indent: options.indent ?? ' ',
indent: (_a = options.indent) !== null && _a !== void 0 ? _a : ' ',
});

@@ -56,3 +57,3 @@ // Import httr

// Construct payload
const payload = JSON.stringify(postData?.text);
const payload = JSON.stringify(postData === null || postData === void 0 ? void 0 : postData.text);
if (payload) {

@@ -93,3 +94,3 @@ push(`payload <- ${payload}`);

const setAccept = acceptHeader ? `accept("${(0, escape_js_1.escapeForDoubleQuotes)(acceptHeader)}")` : undefined;
const setContentType = `content_type("${(0, escape_js_1.escapeForDoubleQuotes)(postData?.mimeType ?? 'application/octet-stream')}")`;
const setContentType = `content_type("${(0, escape_js_1.escapeForDoubleQuotes)((_b = postData === null || postData === void 0 ? void 0 : postData.mimeType) !== null && _b !== void 0 ? _b : 'application/octet-stream')}")`;
const otherHeaders = Object.entries(allHeaders)

@@ -96,0 +97,0 @@ // These headers are all handled separately:

@@ -40,3 +40,3 @@ "use strict";

push(` METHOD = '${method.toUpperCase()}'`);
push(` REQUEST_HAS_BODY = '${postData?.text ? 'true' : 'false'}'`);
push(` REQUEST_HAS_BODY = '${(postData === null || postData === void 0 ? void 0 : postData.text) ? 'true' : 'false'}'`);
push(' RESPONSE_HAS_BODY = true');

@@ -63,3 +63,3 @@ push('end');

}
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
push(`request.body = ${JSON.stringify(postData.text)}`);

@@ -66,0 +66,0 @@ }

@@ -49,2 +49,3 @@ "use strict";

convert: ({ fullUrl, method, httpVersion, headersObj, allHeaders, postData }, options = {}) => {
var _a;
const { binary = false, globOff = false, indent = ' ', insecureSkipVerify = false, prettifyJson = false, short = false, } = options;

@@ -74,3 +75,3 @@ const { push, join } = new code_builder_js_1.CodeBuilder({

// if multipart form data, we want to remove the boundary
if (postData?.mimeType === 'multipart/form-data') {
if ((postData === null || postData === void 0 ? void 0 : postData.mimeType) === 'multipart/form-data') {
const contentTypeHeaderName = (0, headers_js_1.getHeaderName)(headersObj, 'content-type');

@@ -101,5 +102,5 @@ if (contentTypeHeaderName) {

// construct post params
switch (postData?.mimeType) {
switch (postData === null || postData === void 0 ? void 0 : postData.mimeType) {
case 'multipart/form-data':
postData.params?.forEach(param => {
(_a = postData.params) === null || _a === void 0 ? void 0 : _a.forEach(param => {
let post = '';

@@ -106,0 +107,0 @@ if (param.fileName) {

@@ -92,3 +92,3 @@ "use strict";

});
if (postData?.mimeType === 'application/x-www-form-urlencoded') {
if ((postData === null || postData === void 0 ? void 0 : postData.mimeType) === 'application/x-www-form-urlencoded') {
// construct post params

@@ -108,3 +108,3 @@ if (postData.params && postData.params.length) {

unshift(`http ${cliFlags}${method} ${url}`);
if (raw && postData?.text) {
if (raw && (postData === null || postData === void 0 ? void 0 : postData.text)) {
const postDataText = (0, shell_js_1.quote)(postData.text);

@@ -111,0 +111,0 @@ unshift(`echo ${postDataText} | `);

@@ -45,3 +45,3 @@ "use strict";

});
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
push(`--body-data ${(0, shell_js_1.escape)((0, shell_js_1.quote)(postData.text))}`);

@@ -48,0 +48,0 @@ }

@@ -23,2 +23,3 @@ "use strict";

convert: ({ allHeaders, postData, fullUrl, method }, options) => {
var _a;
const opts = {

@@ -51,3 +52,3 @@ indent: ' ',

blank();
if (postData.params?.length) {
if ((_a = postData.params) === null || _a === void 0 ? void 0 : _a.length) {
const [head, ...tail] = postData.params;

@@ -54,0 +55,0 @@ push(`let postData = NSMutableData(data: "${head.name}=${head.value}".data(using: String.Encoding.utf8)!)`);

@@ -56,4 +56,4 @@ const DEFAULT_INDENTATION_CHARACTER = '';

this.indentationCharacter = indent || DEFAULT_INDENTATION_CHARACTER;
this.lineJoin = join ?? DEFAULT_LINE_JOIN;
this.lineJoin = join !== null && join !== void 0 ? join : DEFAULT_LINE_JOIN;
}
}

@@ -6,2 +6,2 @@ import { targets } from '../targets/targets.js';

}));
export const extname = (targetId) => targets[targetId]?.info.extname || '';
export const extname = (targetId) => { var _a; return ((_a = targets[targetId]) === null || _a === void 0 ? void 0 : _a.info.extname) || ''; };

@@ -35,2 +35,3 @@ import { Blob, FormData } from 'formdata-node';

this.requests = Promise.all(entries.map(({ request }) => {
var _a;
// add optional properties to make validation successful

@@ -45,3 +46,3 @@ const req = {

postData: {
mimeType: request.postData?.mimeType || 'application/octet-stream',
mimeType: ((_a = request.postData) === null || _a === void 0 ? void 0 : _a.mimeType) || 'application/octet-stream',
},

@@ -54,2 +55,3 @@ ...request,

async prepare(harRequest) {
var _a, _b, _c, _d;
const request = {

@@ -88,7 +90,7 @@ ...harRequest,

// construct Cookie header
const cookies = request.cookies?.map(({ name, value }) => `${encodeURIComponent(name)}=${encodeURIComponent(value)}`);
if (cookies?.length) {
const cookies = (_a = request.cookies) === null || _a === void 0 ? void 0 : _a.map(({ name, value }) => `${encodeURIComponent(name)}=${encodeURIComponent(value)}`);
if (cookies === null || cookies === void 0 ? void 0 : cookies.length) {
request.allHeaders.cookie = cookies.join('; ');
}
switch (request.postData?.mimeType) {
switch ((_b = request.postData) === null || _b === void 0 ? void 0 : _b.mimeType) {
case 'multipart/mixed':

@@ -101,3 +103,3 @@ case 'multipart/related':

request.postData.mimeType = 'multipart/form-data';
if (request.postData?.params) {
if ((_c = request.postData) === null || _c === void 0 ? void 0 : _c.params) {
const form = new FormData();

@@ -108,3 +110,3 @@ // TODO: THIS ABSOLUTELY MUST BE REMOVED.

const boundary = '---011000010111000001101001'; // this is binary for "api". yep.
request.postData?.params.forEach(param => {
(_d = request.postData) === null || _d === void 0 ? void 0 : _d.params.forEach(param => {
const name = param.name;

@@ -111,0 +113,0 @@ const value = param.value || '';

@@ -32,3 +32,3 @@ import { CodeBuilder } from '../../../helpers/code-builder.js';

}
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
blank();

@@ -35,0 +35,0 @@ push(`curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, ${JSON.stringify(postData.text)});`);

@@ -94,3 +94,3 @@ /**

convert: ({ queryObj, method, postData, url, allHeaders }, options) => {
const { push, join } = new CodeBuilder({ indent: options?.indent });
const { push, join } = new CodeBuilder({ indent: options === null || options === void 0 ? void 0 : options.indent });
const methods = ['get', 'post', 'put', 'delete', 'patch', 'head', 'options'];

@@ -106,3 +106,3 @@ method = method.toLowerCase();

};
switch (postData?.mimeType) {
switch (postData === null || postData === void 0 ? void 0 : postData.mimeType) {
case 'application/json':

@@ -109,0 +109,0 @@ {

@@ -38,2 +38,3 @@ import { CodeBuilder } from '../../../helpers/code-builder.js';

convert: ({ allHeaders, postData, method, fullUrl }, options) => {
var _a, _b;
const opts = {

@@ -96,3 +97,3 @@ indent: ' ',

}
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
const contentType = postData.mimeType;

@@ -103,3 +104,3 @@ switch (contentType) {

push('{', 1);
postData.params?.forEach(param => {
(_a = postData.params) === null || _a === void 0 ? void 0 : _a.forEach(param => {
push(`{ "${param.name}", "${param.value}" },`, 2);

@@ -112,3 +113,3 @@ });

push('{', 1);
postData.params?.forEach(param => {
(_b = postData.params) === null || _b === void 0 ? void 0 : _b.forEach(param => {
push(`new StringContent(${JSON.stringify(param.value || '')})`, 2);

@@ -134,3 +135,3 @@ push('{', 2);

default:
push(`Content = new StringContent(${JSON.stringify(postData?.text || '')})`, 1);
push(`Content = new StringContent(${JSON.stringify((postData === null || postData === void 0 ? void 0 : postData.text) || '')})`, 1);
push('{', 1);

@@ -137,0 +138,0 @@ push('Headers =', 2);

@@ -23,6 +23,6 @@ import { CodeBuilder } from '../../../helpers/code-builder.js';

});
cookies?.forEach(({ name, value }) => {
cookies === null || cookies === void 0 ? void 0 : cookies.forEach(({ name, value }) => {
push(`request.AddCookie("${name}", "${value}");`);
});
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
const header = getHeader(allHeaders, 'content-type');

@@ -29,0 +29,0 @@ const text = JSON.stringify(postData.text);

@@ -43,3 +43,3 @@ /**

}
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
push('"strings"', indent);

@@ -79,3 +79,3 @@ }

// If we have body content or not create the var and reader or nil
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
push(`payload := strings.NewReader(${JSON.stringify(postData.text)})`, indent);

@@ -82,0 +82,0 @@ blank();

@@ -55,3 +55,3 @@ /**

// Automatically set Content-Length header if option is on, postData is present and no header already exists.
if (opts.autoContentLength && postData?.text && !headerKeys.includes('content-length')) {
if (opts.autoContentLength && (postData === null || postData === void 0 ? void 0 : postData.text) && !headerKeys.includes('content-length')) {
push(`Content-Length: ${postData.text.length}`);

@@ -64,3 +64,3 @@ }

// RFC 7230 Section 3.3. Message Body
const messageBody = postData?.text || '';
const messageBody = (postData === null || postData === void 0 ? void 0 : postData.text) || '';
// RFC 7230 Section 3. Message Format

@@ -67,0 +67,0 @@ // Extra CRLF separating the headers from the body.

@@ -31,3 +31,3 @@ /**

});
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
push(`.setBody(${JSON.stringify(postData.text)})`, 1);

@@ -34,0 +34,0 @@ }

@@ -30,3 +30,3 @@ /**

});
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
push(`.method("${method.toUpperCase()}", HttpRequest.BodyPublishers.ofString(${JSON.stringify(postData.text)}))`, 2);

@@ -33,0 +33,0 @@ }

@@ -29,3 +29,3 @@ /**

blank();
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
if (postData.boundary) {

@@ -42,3 +42,3 @@ push(`MediaType mediaType = MediaType.parse("${postData.mimeType}; boundary=${postData.boundary}");`);

if (!methods.includes(method.toUpperCase())) {
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
push(`.method("${method.toUpperCase()}", body)`, 1);

@@ -51,3 +51,3 @@ }

else if (methodsWithBody.includes(method.toUpperCase())) {
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
push(`.${method.toLowerCase()}(body)`, 1);

@@ -54,0 +54,0 @@ }

@@ -36,3 +36,3 @@ /**

});
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
push(`.body(${JSON.stringify(postData.text)})`, 1);

@@ -39,0 +39,0 @@ }

@@ -37,3 +37,3 @@ /**

}
switch (postData?.mimeType) {
switch (postData === null || postData === void 0 ? void 0 : postData.mimeType) {
case 'application/x-www-form-urlencoded':

@@ -67,3 +67,3 @@ if (postData.params) {

default:
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
requestOptions.data = postData.text;

@@ -70,0 +70,0 @@ }

@@ -37,3 +37,3 @@ /**

push(`const url = '${fullUrl}';`);
switch (postData?.mimeType) {
switch (postData === null || postData === void 0 ? void 0 : postData.mimeType) {
case 'application/x-www-form-urlencoded':

@@ -62,3 +62,3 @@ options.body = postData.paramsObj ? postData.paramsObj : postData.text;

default:
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
options.body = postData.text;

@@ -84,3 +84,3 @@ }

blank();
if (postData?.params && postData.mimeType === 'multipart/form-data') {
if ((postData === null || postData === void 0 ? void 0 : postData.params) && postData.mimeType === 'multipart/form-data') {
push('options.body = form;');

@@ -87,0 +87,0 @@ blank();

@@ -21,2 +21,3 @@ /**

convert: ({ fullUrl, method, allHeaders, postData }, options) => {
var _a;
const opts = {

@@ -34,3 +35,3 @@ indent: ' ',

};
switch (postData?.mimeType) {
switch (postData === null || postData === void 0 ? void 0 : postData.mimeType) {
case 'application/x-www-form-urlencoded':

@@ -57,3 +58,3 @@ settings.data = postData.paramsObj ? postData.paramsObj : postData.text;

if (hasHeader(allHeaders, 'content-type')) {
if (getHeader(allHeaders, 'content-type')?.includes('boundary')) {
if ((_a = getHeader(allHeaders, 'content-type')) === null || _a === void 0 ? void 0 : _a.includes('boundary')) {
const headerName = getHeaderName(allHeaders, 'content-type');

@@ -68,3 +69,3 @@ if (headerName) {

default:
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
settings.data = postData.text;

@@ -71,0 +72,0 @@ }

@@ -22,2 +22,3 @@ /**

convert: ({ postData, allHeaders, method, fullUrl }, options) => {
var _a;
const opts = {

@@ -29,3 +30,3 @@ indent: ' ',

const { blank, push, join } = new CodeBuilder({ indent: opts.indent });
switch (postData?.mimeType) {
switch (postData === null || postData === void 0 ? void 0 : postData.mimeType) {
case 'application/json':

@@ -47,3 +48,3 @@ push(`const data = JSON.stringify(${stringifyObject(postData.jsonObj, {

if (hasHeader(allHeaders, 'content-type')) {
if (getHeader(allHeaders, 'content-type')?.includes('boundary')) {
if ((_a = getHeader(allHeaders, 'content-type')) === null || _a === void 0 ? void 0 : _a.includes('boundary')) {
const headerName = getHeaderName(allHeaders, 'content-type');

@@ -58,3 +59,3 @@ if (headerName) {

default:
push(`const data = ${postData?.text ? `'${postData.text}'` : 'null'};`);
push(`const data = ${(postData === null || postData === void 0 ? void 0 : postData.text) ? `'${postData.text}'` : 'null'};`);
blank();

@@ -61,0 +62,0 @@ }

@@ -29,3 +29,3 @@ /**

blank();
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
if (postData.boundary) {

@@ -42,3 +42,3 @@ push(`val mediaType = MediaType.parse("${postData.mimeType}; boundary=${postData.boundary}")`);

if (!methods.includes(method.toUpperCase())) {
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
push(`.method("${method.toUpperCase()}", body)`, 1);

@@ -51,3 +51,3 @@ }

else if (methodsWithBody.includes(method.toUpperCase())) {
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
push(`.${method.toLowerCase()}(body)`, 1);

@@ -54,0 +54,0 @@ }

@@ -36,3 +36,3 @@ /**

}
switch (postData?.mimeType) {
switch (postData === null || postData === void 0 ? void 0 : postData.mimeType) {
case 'application/x-www-form-urlencoded':

@@ -59,3 +59,3 @@ if (postData.params) {

blank();
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
reqOpts.data = postData.text;

@@ -62,0 +62,0 @@ }

@@ -21,2 +21,3 @@ /**

convert: ({ method, fullUrl, postData, headersObj, cookies }, options) => {
var _a;
const opts = {

@@ -36,7 +37,7 @@ indent: ' ',

}
switch (postData?.mimeType) {
switch (postData === null || postData === void 0 ? void 0 : postData.mimeType) {
case 'application/x-www-form-urlencoded':
unshift("const { URLSearchParams } = require('url');");
push('const encodedParams = new URLSearchParams();');
postData.params?.forEach(param => {
(_a = postData.params) === null || _a === void 0 ? void 0 : _a.forEach(param => {
push(`encodedParams.set('${param.name}', '${param.value}');`);

@@ -77,3 +78,3 @@ });

default:
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
reqOpts.body = postData.text;

@@ -105,3 +106,3 @@ }

}
if (postData?.params && postData.mimeType === 'multipart/form-data') {
if ((postData === null || postData === void 0 ? void 0 : postData.params) && postData.mimeType === 'multipart/form-data') {
push('options.body = formData;');

@@ -108,0 +109,0 @@ }

@@ -47,3 +47,3 @@ /**

blank();
switch (postData?.mimeType) {
switch (postData === null || postData === void 0 ? void 0 : postData.mimeType) {
case 'application/x-www-form-urlencoded':

@@ -67,3 +67,3 @@ if (postData.paramsObj) {

default:
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
push(`req.write(${stringifyObject(postData.text, { indent })});`);

@@ -70,0 +70,0 @@ }

@@ -38,3 +38,3 @@ /**

}
switch (postData?.mimeType) {
switch (postData === null || postData === void 0 ? void 0 : postData.mimeType) {
case 'application/x-www-form-urlencoded':

@@ -77,3 +77,3 @@ reqOpts.form = postData.paramsObj;

default:
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
reqOpts.body = postData.text;

@@ -80,0 +80,0 @@ }

@@ -48,3 +48,3 @@ /**

}
switch (postData?.mimeType) {
switch (postData === null || postData === void 0 ? void 0 : postData.mimeType) {
case 'application/x-www-form-urlencoded':

@@ -90,3 +90,3 @@ if (postData.paramsObj) {

default:
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
push(`req.send(${stringifyObject(postData.text, { indent: opts.indent })});`);

@@ -93,0 +93,0 @@ blank();

@@ -20,2 +20,3 @@ /**

convert: ({ allHeaders, postData, method, fullUrl }, options) => {
var _a;
const opts = {

@@ -44,3 +45,3 @@ indent: ' ',

case 'application/x-www-form-urlencoded':
if (postData.params?.length) {
if ((_a = postData.params) === null || _a === void 0 ? void 0 : _a.length) {
// By appending parameters one by one in the resulting snippet,

@@ -47,0 +48,0 @@ // we make it easier for the user to edit it according to his or her needs after pasting.

@@ -44,3 +44,3 @@ /**

// Add body
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
// Just text

@@ -52,3 +52,3 @@ push(`let body = Cohttp_lwt_body.of_string ${JSON.stringify(postData.text)} in`);

const h = headers.length ? '~headers ' : '';
const b = postData?.text ? '~body ' : '';
const b = (postData === null || postData === void 0 ? void 0 : postData.text) ? '~body ' : '';
const m = methods.includes(method.toLowerCase())

@@ -55,0 +55,0 @@ ? `\`${method.toUpperCase()}`

@@ -71,3 +71,3 @@ /**

{
escape: !postData?.jsonObj,
escape: !(postData === null || postData === void 0 ? void 0 : postData.jsonObj),
name: 'CURLOPT_POSTFIELDS',

@@ -74,0 +74,0 @@ value: postData

@@ -22,2 +22,3 @@ /**

convert: ({ postData, fullUrl, method, cookies, headersObj }, options) => {
var _a;
const opts = {

@@ -36,3 +37,3 @@ closingTag: false,

}
switch (postData?.mimeType) {
switch (postData === null || postData === void 0 ? void 0 : postData.mimeType) {
case 'application/x-www-form-urlencoded':

@@ -68,3 +69,3 @@ requestPush(`'form_params' => ${convertType(postData.paramsObj, opts.indent + opts.indent, opts.indent)},`, 1);

if (hasHeader(headersObj, 'content-type')) {
if (getHeader(headersObj, 'content-type')?.indexOf('boundary')) {
if ((_a = getHeader(headersObj, 'content-type')) === null || _a === void 0 ? void 0 : _a.indexOf('boundary')) {
const headerName = getHeaderName(headersObj, 'content-type');

@@ -80,3 +81,3 @@ if (headerName) {

default:
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
requestPush(`'body' => ${convertType(postData.text)},`, 1);

@@ -83,0 +84,0 @@ }

@@ -50,3 +50,3 @@ /**

}
switch (postData?.mimeType) {
switch (postData === null || postData === void 0 ? void 0 : postData.mimeType) {
case 'application/x-www-form-urlencoded':

@@ -63,3 +63,3 @@ push(`$request->setContentType(${convertType(postData.mimeType)});`);

default:
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
push(`$request->setBody(${convertType(postData.text)});`);

@@ -66,0 +66,0 @@ blank();

@@ -21,2 +21,3 @@ /**

convert: ({ postData, headersObj, method, queryObj, cookiesObj, url }, options = {}) => {
var _a;
const { closingTag = false, indent = ' ', noTags = false, shortTags = false } = options;

@@ -32,3 +33,3 @@ const { push, blank, join } = new CodeBuilder({ indent });

blank();
switch (postData?.mimeType) {
switch (postData === null || postData === void 0 ? void 0 : postData.mimeType) {
case 'application/x-www-form-urlencoded':

@@ -66,3 +67,3 @@ push('$body = new http\\Message\\Body;');

if (hasHeader(headersObj, 'content-type')) {
if (getHeader(headersObj, 'content-type')?.indexOf('boundary')) {
if ((_a = getHeader(headersObj, 'content-type')) === null || _a === void 0 ? void 0 : _a.indexOf('boundary')) {
const headerName = getHeaderName(headersObj, 'content-type');

@@ -84,3 +85,3 @@ if (headerName) {

default:
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
push('$body = new http\\Message\\Body;');

@@ -87,0 +88,0 @@ push(`$body->append(${convertType(postData.text)});`);

@@ -37,3 +37,3 @@ import { CodeBuilder } from '../../helpers/code-builder.js';

}
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
commandOptions.push(`-ContentType '${escapeString(getHeader(allHeaders, 'content-type'), {

@@ -40,0 +40,0 @@ delimiter: "'",

@@ -39,3 +39,3 @@ /**

// Create payload string if it exists
const payload = JSON.stringify(postData?.text);
const payload = JSON.stringify(postData === null || postData === void 0 ? void 0 : postData.text);
if (payload) {

@@ -42,0 +42,0 @@ push(`payload = ${payload}`);

@@ -50,3 +50,3 @@ /**

let jsonPayload = false;
switch (postData?.mimeType) {
switch (postData === null || postData === void 0 ? void 0 : postData.mimeType) {
case 'application/json':

@@ -53,0 +53,0 @@ if (postData.jsonObj) {

@@ -21,5 +21,6 @@ /**

convert: ({ url, queryObj, queryString, postData, allHeaders, method }, options = {}) => {
var _a, _b;
// Start snippet
const { push, blank, join } = new CodeBuilder({
indent: options.indent ?? ' ',
indent: (_a = options.indent) !== null && _a !== void 0 ? _a : ' ',
});

@@ -53,3 +54,3 @@ // Import httr

// Construct payload
const payload = JSON.stringify(postData?.text);
const payload = JSON.stringify(postData === null || postData === void 0 ? void 0 : postData.text);
if (payload) {

@@ -90,3 +91,3 @@ push(`payload <- ${payload}`);

const setAccept = acceptHeader ? `accept("${escapeForDoubleQuotes(acceptHeader)}")` : undefined;
const setContentType = `content_type("${escapeForDoubleQuotes(postData?.mimeType ?? 'application/octet-stream')}")`;
const setContentType = `content_type("${escapeForDoubleQuotes((_b = postData === null || postData === void 0 ? void 0 : postData.mimeType) !== null && _b !== void 0 ? _b : 'application/octet-stream')}")`;
const otherHeaders = Object.entries(allHeaders)

@@ -93,0 +94,0 @@ // These headers are all handled separately:

@@ -37,3 +37,3 @@ import { CodeBuilder } from '../../../helpers/code-builder.js';

push(` METHOD = '${method.toUpperCase()}'`);
push(` REQUEST_HAS_BODY = '${postData?.text ? 'true' : 'false'}'`);
push(` REQUEST_HAS_BODY = '${(postData === null || postData === void 0 ? void 0 : postData.text) ? 'true' : 'false'}'`);
push(' RESPONSE_HAS_BODY = true');

@@ -60,3 +60,3 @@ push('end');

}
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
push(`request.body = ${JSON.stringify(postData.text)}`);

@@ -63,0 +63,0 @@ }

@@ -46,2 +46,3 @@ /**

convert: ({ fullUrl, method, httpVersion, headersObj, allHeaders, postData }, options = {}) => {
var _a;
const { binary = false, globOff = false, indent = ' ', insecureSkipVerify = false, prettifyJson = false, short = false, } = options;

@@ -71,3 +72,3 @@ const { push, join } = new CodeBuilder({

// if multipart form data, we want to remove the boundary
if (postData?.mimeType === 'multipart/form-data') {
if ((postData === null || postData === void 0 ? void 0 : postData.mimeType) === 'multipart/form-data') {
const contentTypeHeaderName = getHeaderName(headersObj, 'content-type');

@@ -98,5 +99,5 @@ if (contentTypeHeaderName) {

// construct post params
switch (postData?.mimeType) {
switch (postData === null || postData === void 0 ? void 0 : postData.mimeType) {
case 'multipart/form-data':
postData.params?.forEach(param => {
(_a = postData.params) === null || _a === void 0 ? void 0 : _a.forEach(param => {
let post = '';

@@ -103,0 +104,0 @@ if (param.fileName) {

@@ -89,3 +89,3 @@ /**

});
if (postData?.mimeType === 'application/x-www-form-urlencoded') {
if ((postData === null || postData === void 0 ? void 0 : postData.mimeType) === 'application/x-www-form-urlencoded') {
// construct post params

@@ -105,3 +105,3 @@ if (postData.params && postData.params.length) {

unshift(`http ${cliFlags}${method} ${url}`);
if (raw && postData?.text) {
if (raw && (postData === null || postData === void 0 ? void 0 : postData.text)) {
const postDataText = quote(postData.text);

@@ -108,0 +108,0 @@ unshift(`echo ${postDataText} | `);

@@ -42,3 +42,3 @@ /**

});
if (postData?.text) {
if (postData === null || postData === void 0 ? void 0 : postData.text) {
push(`--body-data ${escape(quote(postData.text))}`);

@@ -45,0 +45,0 @@ }

@@ -20,2 +20,3 @@ /**

convert: ({ allHeaders, postData, fullUrl, method }, options) => {
var _a;
const opts = {

@@ -48,3 +49,3 @@ indent: ' ',

blank();
if (postData.params?.length) {
if ((_a = postData.params) === null || _a === void 0 ? void 0 : _a.length) {
const [head, ...tail] = postData.params;

@@ -51,0 +52,0 @@ push(`let postData = NSMutableData(data: "${head.name}=${head.value}".data(using: String.Encoding.utf8)!)`);

{
"version": "3.0.2",
"version": "3.0.3",
"name": "httpsnippet-lite",

@@ -4,0 +4,0 @@ "description": "HTTP Request snippet generator for *most* languages",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc