httpsnippet
Advanced tools
Comparing version 1.16.7 to 1.18.0
{ | ||
"version": "1.16.7", | ||
"version": "1.18.0", | ||
"name": "httpsnippet", | ||
@@ -53,3 +53,3 @@ "description": "HTTP Request snippet generator for *most* languages", | ||
"test": "mocha --no-timeouts", | ||
"posttest": "npm run coverage", | ||
"posttest": "exit 0 && npm run coverage", | ||
"coverage": "istanbul cover --dir coverage _mocha -- --fgrep 'Request Validation' --invert -R dot", | ||
@@ -66,4 +66,4 @@ "codeclimate": "codeclimate < coverage/lcov.info" | ||
"coverage/**", | ||
"CONTRIBUTING.md", | ||
"test/fixtures/**" | ||
"**/node_modules/**", | ||
"**/fixtures/**" | ||
] | ||
@@ -90,4 +90,5 @@ }, | ||
"har-validator": "^5.0.0", | ||
"pinkie-promise": "^2.0.0" | ||
"pinkie-promise": "^2.0.0", | ||
"stringify-object": "^3.3.0" | ||
} | ||
} |
@@ -11,6 +11,2 @@ # HTTP Snippet [![version][npm-version]][npm-url] [![License][npm-license]][license-url] | ||
[![Downloads][npm-downloads]][npm-url] | ||
[![Code Climate][codeclimate-quality]][codeclimate-url] | ||
[![Coverage Status][codeclimate-coverage]][codeclimate-url] | ||
[![Dependencies][david-image]][david-url] | ||
[![Gitter][gitter-image]][gitter-url] | ||
@@ -175,5 +171,5 @@ ## Install | ||
For a info on creating new conversion targets, please review this [guideline](https://github.com/Mashape/httpsnippet/wiki/Creating-Targets) | ||
For info on creating new conversion targets, please review this [guideline](https://github.com/Mashape/httpsnippet/wiki/Creating-Targets) | ||
More over, if your pull request contains JavaScript patches or features, you must include relevant unit tests. | ||
Moreover, if your pull request contains JavaScript patches or features, you must include relevant unit tests. | ||
@@ -200,8 +196,8 @@ Editor preferences are available in the [editor config](.editorconfig) for easy use in common text editors. Read more and download plugins at <http://editorconfig.org>. | ||
[MIT](LICENSE) © [Mashape](https://www.mashape.com) | ||
[MIT](LICENSE) © [Kong](https://konghq.com) | ||
[license-url]: https://github.com/Mashape/httpsnippet/blob/master/LICENSE | ||
[license-url]: https://github.com/Kong/httpsnippet/blob/master/LICENSE | ||
[travis-url]: https://travis-ci.org/Mashape/httpsnippet | ||
[travis-image]: https://img.shields.io/travis/Mashape/httpsnippet.svg?style=flat-square | ||
[travis-url]: https://travis-ci.org/Kong/httpsnippet | ||
[travis-image]: https://img.shields.io/travis/Kong/httpsnippet.svg?style=flat-square | ||
@@ -213,10 +209,1 @@ [npm-url]: https://www.npmjs.com/package/httpsnippet | ||
[codeclimate-url]: https://codeclimate.com/github/Mashape/httpsnippet | ||
[codeclimate-quality]: https://img.shields.io/codeclimate/github/Mashape/httpsnippet.svg?style=flat-square | ||
[codeclimate-coverage]: https://img.shields.io/codeclimate/coverage/github/Mashape/httpsnippet.svg?style=flat-square | ||
[david-url]: https://david-dm.org/Mashape/httpsnippet | ||
[david-image]: https://img.shields.io/david/Mashape/httpsnippet.svg?style=flat-square | ||
[gitter-url]: https://gitter.im/Mashape/httpsnippet | ||
[gitter-image]: https://img.shields.io/badge/Gitter-Join%20Chat-blue.svg?style=flat-square |
@@ -9,2 +9,8 @@ 'use strict' | ||
// If we already have it as array just push the value | ||
if (obj[pair.name] instanceof Array) { | ||
obj[pair.name].push(pair.value) | ||
return obj | ||
} | ||
// convert to array | ||
@@ -11,0 +17,0 @@ var arr = [ |
@@ -16,3 +16,3 @@ 'use strict' | ||
if (!safe.test(value)) { | ||
return util.format('\'%s\'', value.replace(/'/g, "\'\\'\'")) | ||
return util.format('\'%s\'', value.replace(/'/g, "'\\''")) | ||
} | ||
@@ -19,0 +19,0 @@ |
@@ -10,3 +10,2 @@ 'use strict' | ||
var url = require('url') | ||
var util = require('util') | ||
var validate = require('har-validator/lib/async') | ||
@@ -18,3 +17,3 @@ | ||
var self = this | ||
var input = util._extend({}, data) | ||
var input = Object.assign({}, data) | ||
@@ -75,3 +74,3 @@ // prep the main container | ||
// loweCase header keys | ||
request.headersObj = request.headers.reduceRight(function (headers, header) { | ||
request.headersObj = request.headers.reduce(function (headers, header) { | ||
headers[header.name.toLowerCase()] = header.value | ||
@@ -162,3 +161,3 @@ return headers | ||
// create allHeaders object | ||
request.allHeaders = util._extend(request.allHeaders, request.headersObj) | ||
request.allHeaders = Object.assign(request.allHeaders, request.headersObj) | ||
@@ -169,3 +168,3 @@ // deconstruct the uri | ||
// merge all possible queryString values | ||
request.queryObj = util._extend(request.queryObj, request.uriObj.query) | ||
request.queryObj = Object.assign(request.queryObj, request.uriObj.query) | ||
@@ -232,3 +231,3 @@ // reset uriObj values for a clean url | ||
return Object.keys(targets).map(function (key) { | ||
var target = util._extend({}, targets[key].info) | ||
var target = Object.assign({}, targets[key].info) | ||
var clients = Object.keys(targets[key]) | ||
@@ -235,0 +234,0 @@ |
@@ -64,3 +64,3 @@ /** | ||
case 'string': | ||
return '"' + js.replace(/\"/g, '\\"') + '"' | ||
return '"' + js.replace(/"/g, '\\"') + '"' | ||
case 'file': | ||
@@ -99,3 +99,3 @@ return js.toString() | ||
var params = {headers: source.allHeaders, | ||
'query-params': source.queryObj} | ||
'query-params': source.queryObj} | ||
@@ -120,6 +120,6 @@ switch (source.postData.mimeType) { | ||
return {name: x.name, | ||
content: new File(x.fileName)} | ||
content: new File(x.fileName)} | ||
} else { | ||
return {name: x.name, | ||
content: x.value} | ||
content: x.value} | ||
} | ||
@@ -126,0 +126,0 @@ }) |
@@ -13,3 +13,2 @@ /** | ||
var util = require('util') | ||
var CodeBuilder = require('../../helpers/code-builder') | ||
@@ -22,3 +21,3 @@ | ||
// Define Options | ||
var opts = util._extend({ | ||
var opts = Object.assign({ | ||
showBoilerplate: true, | ||
@@ -25,0 +24,0 @@ checkErrors: false, |
@@ -13,7 +13,6 @@ /** | ||
var util = require('util') | ||
var CodeBuilder = require('../../helpers/code-builder') | ||
module.exports = function (source, options) { | ||
var opts = util._extend({ | ||
var opts = Object.assign({ | ||
indent: ' ' | ||
@@ -20,0 +19,0 @@ }, options) |
@@ -13,7 +13,6 @@ /** | ||
var util = require('util') | ||
var CodeBuilder = require('../../helpers/code-builder') | ||
module.exports = function (source, options) { | ||
var opts = util._extend({ | ||
var opts = Object.assign({ | ||
indent: ' ' | ||
@@ -20,0 +19,0 @@ }, options) |
@@ -13,7 +13,6 @@ /** | ||
var util = require('util') | ||
var CodeBuilder = require('../../helpers/code-builder') | ||
module.exports = function (source, options) { | ||
var opts = util._extend({ | ||
var opts = Object.assign({ | ||
indent: ' ' | ||
@@ -20,0 +19,0 @@ }, options) |
@@ -13,7 +13,6 @@ /** | ||
var util = require('util') | ||
var CodeBuilder = require('../../helpers/code-builder') | ||
module.exports = function (source, options) { | ||
var opts = util._extend({ | ||
var opts = Object.assign({ | ||
indent: ' ', | ||
@@ -20,0 +19,0 @@ cors: true |
@@ -13,7 +13,7 @@ /** | ||
var util = require('util') | ||
var stringifyObject = require('stringify-object') | ||
var CodeBuilder = require('../../helpers/code-builder') | ||
module.exports = function (source, options) { | ||
var opts = util._extend({ | ||
var opts = Object.assign({ | ||
indent: ' ' | ||
@@ -55,4 +55,5 @@ }, options) | ||
code.unshift('var qs = require("querystring");') | ||
code.push('req.write(qs.stringify(%s));', util.inspect(source.postData.paramsObj, { | ||
depth: null | ||
code.push('req.write(qs.stringify(%s));', stringifyObject(source.postData.paramsObj, { | ||
indent: ' ', | ||
inlineCharacterLimit: 80 | ||
})) | ||
@@ -64,4 +65,5 @@ } | ||
if (source.postData.jsonObj) { | ||
code.push('req.write(JSON.stringify(%s));', util.inspect(source.postData.jsonObj, { | ||
depth: null | ||
code.push('req.write(JSON.stringify(%s));', stringifyObject(source.postData.jsonObj, { | ||
indent: ' ', | ||
inlineCharacterLimit: 80 | ||
})) | ||
@@ -68,0 +70,0 @@ } |
@@ -14,6 +14,7 @@ /** | ||
var util = require('util') | ||
var stringifyObject = require('stringify-object') | ||
var CodeBuilder = require('../../helpers/code-builder') | ||
module.exports = function (source, options) { | ||
var opts = util._extend({ | ||
var opts = Object.assign({ | ||
indent: ' ' | ||
@@ -57,3 +58,3 @@ }, options) | ||
source.postData.params.forEach(function (param) { | ||
var attachement = {} | ||
var attachment = {} | ||
@@ -68,9 +69,9 @@ if (!param.fileName && !param.fileName && !param.contentType) { | ||
attachement.value = 'fs.createReadStream("' + param.fileName + '")' | ||
attachment.value = 'fs.createReadStream("' + param.fileName + '")' | ||
} else if (param.value) { | ||
attachement.value = param.value | ||
attachment.value = param.value | ||
} | ||
if (param.fileName) { | ||
attachement.options = { | ||
attachment.options = { | ||
filename: param.fileName, | ||
@@ -81,3 +82,3 @@ contentType: param.contentType ? param.contentType : null | ||
reqOpts.formData[param.name] = attachement | ||
reqOpts.formData[param.name] = attachment | ||
}) | ||
@@ -110,3 +111,3 @@ break | ||
code.push('var options = %s;', util.inspect(reqOpts, { depth: null })) | ||
code.push('var options = %s;', stringifyObject(reqOpts, { indent: ' ', inlineCharacterLimit: 80 })) | ||
.blank() | ||
@@ -122,3 +123,3 @@ | ||
return code.join().replace('"JAR"', 'jar').replace(/"fs\.createReadStream\(\\\"(.+)\\\"\)\"/, 'fs.createReadStream("$1")') | ||
return code.join().replace('"JAR"', 'jar').replace(/"fs\.createReadStream\(\\"(.+)\\"\)"/, 'fs.createReadStream("$1")') | ||
} | ||
@@ -125,0 +126,0 @@ |
@@ -13,7 +13,6 @@ /** | ||
var util = require('util') | ||
var CodeBuilder = require('../../helpers/code-builder') | ||
module.exports = function (source, options) { | ||
var opts = util._extend({ | ||
var opts = Object.assign({ | ||
indent: ' ' | ||
@@ -109,3 +108,3 @@ }, options) | ||
return code.join().replace(/"fs\.createReadStream\(\\\"(.+)\\\"\)\"/, 'fs.createReadStream("$1")') | ||
return code.join().replace(/"fs\.createReadStream\(\\"(.+)\\"\)"/, 'fs.createReadStream("$1")') | ||
} | ||
@@ -112,0 +111,0 @@ |
@@ -54,6 +54,6 @@ 'use strict' | ||
case '[object Array]': | ||
var values_representation = value.map(function (v) { | ||
var valuesRepresentation = value.map(function (v) { | ||
return this.literalRepresentation(v) | ||
}.bind(this)) | ||
return '@[ ' + values_representation.join(join) + ' ]' | ||
return '@[ ' + valuesRepresentation.join(join) + ' ]' | ||
case '[object Object]': | ||
@@ -60,0 +60,0 @@ var keyValuePairs = [] |
@@ -13,3 +13,2 @@ /** | ||
var util = require('util') | ||
var helpers = require('./helpers') | ||
@@ -19,3 +18,3 @@ var CodeBuilder = require('../../helpers/code-builder') | ||
module.exports = function (source, options) { | ||
var opts = util._extend({ | ||
var opts = Object.assign({ | ||
indent: ' ', | ||
@@ -22,0 +21,0 @@ pretty: true, |
@@ -13,7 +13,6 @@ /** | ||
var util = require('util') | ||
var CodeBuilder = require('../../helpers/code-builder') | ||
module.exports = function (source, options) { | ||
var opts = util._extend({ | ||
var opts = Object.assign({ | ||
indent: ' ' | ||
@@ -20,0 +19,0 @@ }, options) |
@@ -17,3 +17,3 @@ /** | ||
module.exports = function (source, options) { | ||
var opts = util._extend({ | ||
var opts = Object.assign({ | ||
closingTag: false, | ||
@@ -20,0 +20,0 @@ indent: ' ', |
'use strict' | ||
var convert = function (obj, indent, last_indent) { | ||
var convert = function (obj, indent, lastIndent) { | ||
var i, result | ||
if (!last_indent) { | ||
last_indent = '' | ||
if (!lastIndent) { | ||
lastIndent = '' | ||
} | ||
@@ -20,3 +20,3 @@ | ||
case '[object String]': | ||
result = "'" + obj.replace(/\\/g, '\\\\').replace(/\'/g, "\'") + "'" | ||
result = "'" + obj.replace(/\\/g, '\\\\').replace(/'/g, "'") + "'" | ||
break | ||
@@ -35,3 +35,3 @@ | ||
result = 'array(\n' + indent + result.join(',\n' + indent) + '\n' + last_indent + ')' | ||
result = 'array(\n' + indent + result.join(',\n' + indent) + '\n' + lastIndent + ')' | ||
break | ||
@@ -46,3 +46,3 @@ | ||
} | ||
result = 'array(\n' + indent + result.join(',\n' + indent) + '\n' + last_indent + ')' | ||
result = 'array(\n' + indent + result.join(',\n' + indent) + '\n' + lastIndent + ')' | ||
break | ||
@@ -49,0 +49,0 @@ |
@@ -13,3 +13,2 @@ /** | ||
var util = require('util') | ||
var helpers = require('./helpers') | ||
@@ -19,3 +18,3 @@ var CodeBuilder = require('../../helpers/code-builder') | ||
module.exports = function (source, options) { | ||
var opts = util._extend({ | ||
var opts = Object.assign({ | ||
closingTag: false, | ||
@@ -22,0 +21,0 @@ indent: ' ', |
@@ -13,3 +13,2 @@ /** | ||
var util = require('util') | ||
var helpers = require('./helpers') | ||
@@ -19,3 +18,3 @@ var CodeBuilder = require('../../helpers/code-builder') | ||
module.exports = function (source, options) { | ||
var opts = util._extend({ | ||
var opts = Object.assign({ | ||
closingTag: false, | ||
@@ -22,0 +21,0 @@ indent: ' ', |
@@ -18,3 +18,3 @@ /** | ||
module.exports = function (source, options) { | ||
var opts = util._extend({ | ||
var opts = Object.assign({ | ||
indent: ' ', | ||
@@ -21,0 +21,0 @@ short: false, |
@@ -18,3 +18,3 @@ /** | ||
module.exports = function (source, options) { | ||
var opts = util._extend({ | ||
var opts = Object.assign({ | ||
body: false, | ||
@@ -82,3 +82,3 @@ cert: false, | ||
if (util.isArray(value)) { | ||
if (Array.isArray(value)) { | ||
value.forEach(function (val) { | ||
@@ -85,0 +85,0 @@ code.push('%s==%s', name, shell.quote(val)) |
@@ -18,3 +18,3 @@ /** | ||
module.exports = function (source, options) { | ||
var opts = util._extend({ | ||
var opts = Object.assign({ | ||
indent: ' ', | ||
@@ -21,0 +21,0 @@ short: false, |
@@ -13,3 +13,2 @@ /** | ||
var util = require('util') | ||
var helpers = require('./helpers') | ||
@@ -19,3 +18,3 @@ var CodeBuilder = require('../../helpers/code-builder') | ||
module.exports = function (source, options) { | ||
var opts = util._extend({ | ||
var opts = Object.assign({ | ||
indent: ' ', | ||
@@ -22,0 +21,0 @@ pretty: true, |
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
97328
10
2596
206
+ Addedstringify-object@^3.3.0
+ Addedget-own-enumerable-property-symbols@3.0.2(transitive)
+ Addedis-obj@1.0.1(transitive)
+ Addedis-regexp@1.0.0(transitive)
+ Addedstringify-object@3.3.0(transitive)