httpsnippet
Advanced tools
Comparing version 3.0.4 to 3.0.5
export declare const go: () => { | ||
[x: string]: unknown; | ||
target: "shell" | "node" | "http" | "r" | "c" | "clojure" | "csharp" | "go" | "java" | "javascript" | "kotlin" | "objc" | "ocaml" | "php" | "powershell" | "python" | "ruby" | "swift"; | ||
target: "shell" | "node" | "http" | "c" | "clojure" | "crystal" | "csharp" | "go" | "java" | "javascript" | "kotlin" | "objc" | "ocaml" | "php" | "powershell" | "python" | "r" | "ruby" | "rust" | "swift"; | ||
client?: string | undefined; | ||
@@ -12,3 +12,3 @@ output?: string | undefined; | ||
[x: string]: unknown; | ||
target: "shell" | "node" | "http" | "r" | "c" | "clojure" | "csharp" | "go" | "java" | "javascript" | "kotlin" | "objc" | "ocaml" | "php" | "powershell" | "python" | "ruby" | "swift"; | ||
target: "shell" | "node" | "http" | "c" | "clojure" | "crystal" | "csharp" | "go" | "java" | "javascript" | "kotlin" | "objc" | "ocaml" | "php" | "powershell" | "python" | "r" | "ruby" | "rust" | "swift"; | ||
client?: string | undefined; | ||
@@ -15,0 +15,0 @@ output?: string | undefined; |
@@ -37,2 +37,7 @@ export declare type PostProcessor = (unreplacedCode: string) => string; | ||
/** | ||
* Add the line to the end of the last line. Creates a new line | ||
* if no lines exist yet. | ||
*/ | ||
pushToLast: (line: string) => void; | ||
/** | ||
* Add an empty line at the end of current lines | ||
@@ -39,0 +44,0 @@ */ |
@@ -66,2 +66,13 @@ "use strict"; | ||
/** | ||
* Add the line to the end of the last line. Creates a new line | ||
* if no lines exist yet. | ||
*/ | ||
this.pushToLast = function (line) { | ||
if (!_this.code) { | ||
_this.push(line); | ||
} | ||
var updatedLine = "".concat(_this.code[_this.code.length - 1]).concat(line); | ||
_this.code[_this.code.length - 1] = updatedLine; | ||
}; | ||
/** | ||
* Add an empty line at the end of current lines | ||
@@ -68,0 +79,0 @@ */ |
@@ -46,25 +46,21 @@ "use strict"; | ||
if (c === '\b') { | ||
return escapeChar + 'b'; | ||
return "".concat(escapeChar, "b"); | ||
} | ||
else if (c === '\t') { | ||
return escapeChar + 't'; | ||
return "".concat(escapeChar, "t"); | ||
} | ||
else if (c === '\n') { | ||
if (escapeNewlines) { | ||
return escapeChar + 'n'; | ||
return "".concat(escapeChar, "n"); | ||
} | ||
else { | ||
return c; // Don't just continue, or this is caught by < \u0020 | ||
} | ||
return c; // Don't just continue, or this is caught by < \u0020 | ||
} | ||
else if (c === '\f') { | ||
return escapeChar + 'f'; | ||
return "".concat(escapeChar, "f"); | ||
} | ||
else if (c === '\r') { | ||
if (escapeNewlines) { | ||
return escapeChar + 'r'; | ||
return "".concat(escapeChar, "r"); | ||
} | ||
else { | ||
return c; // Don't just continue, or this is caught by < \u0020 | ||
} | ||
return c; // Don't just continue, or this is caught by < \u0020 | ||
} | ||
@@ -84,6 +80,5 @@ else if (c === escapeChar) { | ||
} | ||
else { | ||
return c; | ||
} | ||
}).join(''); | ||
return c; | ||
}) | ||
.join(''); | ||
} | ||
@@ -98,5 +93,3 @@ exports.escapeString = escapeString; | ||
*/ | ||
var escapeForSingleQuotes = function (value) { | ||
return escapeString(value, { delimiter: "'" }); | ||
}; | ||
var escapeForSingleQuotes = function (value) { return escapeString(value, { delimiter: "'" }); }; | ||
exports.escapeForSingleQuotes = escapeForSingleQuotes; | ||
@@ -110,5 +103,3 @@ /** | ||
*/ | ||
var escapeForDoubleQuotes = function (value) { | ||
return escapeString(value, { delimiter: '"' }); | ||
}; | ||
var escapeForDoubleQuotes = function (value) { return escapeString(value, { delimiter: '"' }); }; | ||
exports.escapeForDoubleQuotes = escapeForDoubleQuotes; |
@@ -108,3 +108,3 @@ "use strict"; | ||
} | ||
switch (request.postData.mimeType) { | ||
switch (request === null || request === void 0 ? void 0 : request.postData.mimeType) { | ||
case 'multipart/mixed': | ||
@@ -260,5 +260,5 @@ case 'multipart/related': | ||
// add optional properties to make validation successful | ||
var req = __assign({ bodySize: 0, headersSize: 0, headers: [], cookies: [], httpVersion: 'HTTP/1.1', queryString: [], postData: { | ||
var req = __assign(__assign({ bodySize: 0, headersSize: 0, headers: [], cookies: [], httpVersion: 'HTTP/1.1', queryString: [] }, request), { postData: (request === null || request === void 0 ? void 0 : request.postData) || { | ||
mimeType: ((_b = request.postData) === null || _b === void 0 ? void 0 : _b.mimeType) || 'application/octet-stream' | ||
} }, request); | ||
} }); | ||
if ((0, har_validator_1.validateHarRequest)(req)) { | ||
@@ -265,0 +265,0 @@ _this.requests.push(_this.prepare(req)); |
@@ -11,6 +11,15 @@ "use strict"; | ||
var _b = new code_builder_1.CodeBuilder(), push = _b.push, join = _b.join; | ||
var methods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS']; | ||
if (!methods.includes(method.toUpperCase())) { | ||
return 'Method not supported'; | ||
} | ||
var methods = [ | ||
'DEFAULT', | ||
'DELETE', | ||
'GET', | ||
'HEAD', | ||
'MERGE', | ||
'OPTIONS', | ||
'PATCH', | ||
'POST', | ||
'PUT', | ||
'TRACE' | ||
]; | ||
var methodArg = methods.includes(method.toUpperCase()) ? '-Method' : '-CustomMethod'; | ||
var commandOptions = []; | ||
@@ -43,6 +52,9 @@ // Add headers, including the cookies | ||
if (postData.text) { | ||
commandOptions.push("-ContentType '".concat((0, escape_1.escapeString)((0, headers_1.getHeader)(allHeaders, 'content-type'), { delimiter: "'", escapeChar: '`' }), "'")); | ||
commandOptions.push("-ContentType '".concat((0, escape_1.escapeString)((0, headers_1.getHeader)(allHeaders, 'content-type'), { | ||
delimiter: "'", | ||
escapeChar: '`' | ||
}), "'")); | ||
commandOptions.push("-Body '".concat(postData.text, "'")); | ||
} | ||
push("$response = ".concat(command, " -Uri '").concat(fullUrl, "' -Method ").concat(method, " ").concat(commandOptions.join(' '))); | ||
push("$response = ".concat(command, " -Uri '").concat(fullUrl, "' ").concat(methodArg, " ").concat(method, " ").concat(commandOptions.join(' '))); | ||
return join(); | ||
@@ -49,0 +61,0 @@ }; |
@@ -110,5 +110,3 @@ "use strict"; | ||
: undefined; | ||
var setAccept = acceptHeader | ||
? "accept(\"".concat((0, escape_1.escapeForDoubleQuotes)(acceptHeader), "\")") | ||
: undefined; | ||
var setAccept = acceptHeader ? "accept(\"".concat((0, escape_1.escapeForDoubleQuotes)(acceptHeader), "\")") : undefined; | ||
var setContentType = "content_type(\"".concat((0, escape_1.escapeForDoubleQuotes)(postData.mimeType), "\")"); | ||
@@ -126,5 +124,3 @@ var otherHeaders = Object.entries(allHeaders) | ||
.join(', '); | ||
var setHeaders = otherHeaders | ||
? "add_headers(".concat(otherHeaders, ")") | ||
: undefined; | ||
var setHeaders = otherHeaders ? "add_headers(".concat(otherHeaders, ")") : undefined; | ||
// Construct request | ||
@@ -138,5 +134,7 @@ var request = "response <- VERB(\"".concat(method, "\", url"); | ||
} | ||
var headerAdditions = [setHeaders, setContentType, setAccept, setCookies].filter(function (x) { return !!x; }).join(', '); | ||
var headerAdditions = [setHeaders, setContentType, setAccept, setCookies] | ||
.filter(function (x) { return !!x; }) | ||
.join(', '); | ||
if (headerAdditions) { | ||
request += ', ' + headerAdditions; | ||
request += ", ".concat(headerAdditions); | ||
} | ||
@@ -143,0 +141,0 @@ if (postData.text || postData.jsonObj || postData.params) { |
@@ -5,2 +5,3 @@ "use strict"; | ||
var client_1 = require("./native/client"); | ||
var client_2 = require("./faraday/client"); | ||
exports.ruby = { | ||
@@ -14,4 +15,5 @@ info: { | ||
clientsById: { | ||
native: client_1.native | ||
native: client_1.native, | ||
faraday: client_2.faraday | ||
} | ||
}; |
@@ -31,2 +31,3 @@ import { Merge } from 'type-fest'; | ||
clojure: Target; | ||
crystal: Target; | ||
csharp: Target; | ||
@@ -46,2 +47,3 @@ go: Target; | ||
ruby: Target; | ||
rust: Target; | ||
shell: Target; | ||
@@ -48,0 +50,0 @@ swift: Target; |
@@ -6,37 +6,41 @@ "use strict"; | ||
var target_2 = require("./clojure/target"); | ||
var target_3 = require("./csharp/target"); | ||
var target_4 = require("./go/target"); | ||
var target_5 = require("./http/target"); | ||
var target_6 = require("./java/target"); | ||
var target_7 = require("./javascript/target"); | ||
var target_8 = require("./kotlin/target"); | ||
var target_9 = require("./node/target"); | ||
var target_10 = require("./objc/target"); | ||
var target_11 = require("./ocaml/target"); | ||
var target_12 = require("./php/target"); | ||
var target_13 = require("./powershell/target"); | ||
var target_14 = require("./python/target"); | ||
var target_15 = require("./r/target"); | ||
var target_16 = require("./ruby/target"); | ||
var target_17 = require("./shell/target"); | ||
var target_18 = require("./swift/target"); | ||
var target_3 = require("./crystal/target"); | ||
var target_4 = require("./csharp/target"); | ||
var target_5 = require("./go/target"); | ||
var target_6 = require("./http/target"); | ||
var target_7 = require("./java/target"); | ||
var target_8 = require("./javascript/target"); | ||
var target_9 = require("./kotlin/target"); | ||
var target_10 = require("./node/target"); | ||
var target_11 = require("./objc/target"); | ||
var target_12 = require("./ocaml/target"); | ||
var target_13 = require("./php/target"); | ||
var target_14 = require("./powershell/target"); | ||
var target_15 = require("./python/target"); | ||
var target_16 = require("./r/target"); | ||
var target_17 = require("./ruby/target"); | ||
var target_18 = require("./rust/target"); | ||
var target_19 = require("./shell/target"); | ||
var target_20 = require("./swift/target"); | ||
exports.targets = { | ||
c: target_1.c, | ||
clojure: target_2.clojure, | ||
csharp: target_3.csharp, | ||
go: target_4.go, | ||
http: target_5.http, | ||
java: target_6.java, | ||
javascript: target_7.javascript, | ||
kotlin: target_8.kotlin, | ||
node: target_9.node, | ||
objc: target_10.objc, | ||
ocaml: target_11.ocaml, | ||
php: target_12.php, | ||
powershell: target_13.powershell, | ||
python: target_14.python, | ||
r: target_15.r, | ||
ruby: target_16.ruby, | ||
shell: target_17.shell, | ||
swift: target_18.swift | ||
crystal: target_3.crystal, | ||
csharp: target_4.csharp, | ||
go: target_5.go, | ||
http: target_6.http, | ||
java: target_7.java, | ||
javascript: target_8.javascript, | ||
kotlin: target_9.kotlin, | ||
node: target_10.node, | ||
objc: target_11.objc, | ||
ocaml: target_12.ocaml, | ||
php: target_13.php, | ||
powershell: target_14.powershell, | ||
python: target_15.python, | ||
r: target_16.r, | ||
ruby: target_17.ruby, | ||
rust: target_18.rust, | ||
shell: target_19.shell, | ||
swift: target_20.swift | ||
}; | ||
@@ -43,0 +47,0 @@ var isTarget = function (target) { |
{ | ||
"version": "3.0.4", | ||
"version": "3.0.5", | ||
"name": "httpsnippet", | ||
@@ -14,2 +14,3 @@ "description": "HTTP Request snippet generator for *most* languages", | ||
"clojure", | ||
"crystal", | ||
"csharp", | ||
@@ -34,2 +35,3 @@ "curl", | ||
"ruby", | ||
"rust", | ||
"shell", | ||
@@ -77,4 +79,4 @@ "snippet", | ||
"eslint-plugin-simple-import-sort": "^7.0.0", | ||
"jest": "^27.5.1", | ||
"markdownlint-cli2": "^0.5.1", | ||
"jest": "^27.5.1", | ||
"prettier": "^2.6.2", | ||
@@ -81,0 +83,0 @@ "ts-jest": "^27.1.4", |
@@ -5,3 +5,3 @@ # HTTPSnippet | ||
> HTTP Request snippet generator for _many_ languages & tools including: `cURL`, `HTTPie`, `JavaScript`, `Node`, `C`, `Java`, `PHP`, `Objective-C`, `Swift`, `Python`, `Ruby`, `C#`, `Go`, `OCaml` and [more](https://github.com/Kong/httpsnippet/wiki/Targets)! | ||
> HTTP Request snippet generator for _many_ languages & tools including: `cURL`, `HTTPie`, `JavaScript`, `Node`, `C`, `Java`, `PHP`, `Objective-C`, `Swift`, `Python`, `Ruby`, `C#`, `Go`, `OCaml`, `Crystal` and [more](https://github.com/Kong/httpsnippet/wiki/Targets)! | ||
@@ -8,0 +8,0 @@ Relies on the popular [HAR](http://www.softwareishard.com/blog/har-12-spec/#request) format to import data and describe HTTP calls. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
432938
706
9755