har2postman
Advanced tools
Comparing version 0.6.0 to 0.7.0
@@ -24,3 +24,3 @@ const HarToPostman = () => { }; | ||
const items = []; | ||
harContent.log.entries.map( (e) => { | ||
harContent.log.entries.map((e) => { | ||
items.push(generateItem(e, includeTest)); | ||
@@ -117,24 +117,21 @@ }); | ||
const generateItemRequestHeaders = (harRequestHeaders, requestHasBody) => { | ||
const relevantHarHeaders = []; | ||
if (requestHasBody) { | ||
relevantHarHeaders.push('Content-Type'); | ||
} | ||
return filterAndRenameRelevantHeaders(harRequestHeaders, relevantHarHeaders); | ||
return harRequestHeaders.filter(isNotContentTypeHeader(requestHasBody)).filter(isRelevantHeader).map(renameHeaderKey); | ||
}; | ||
const filterAndRenameRelevantHeaders = (harRequestHeaders, relevantHarHeaders) => { | ||
const itemRequestHeaders = []; | ||
relevantHarHeaders.map((relevantHeader) => { | ||
const newItemRequestHeader = harRequestHeaders.find((header) => header.name === relevantHeader); | ||
if (newItemRequestHeader != undefined) { | ||
itemRequestHeaders.push(newItemRequestHeader); | ||
} | ||
}); | ||
itemRequestHeaders.forEach((header) => { | ||
header.key = header.name; | ||
delete header.name; | ||
}); | ||
return itemRequestHeaders; | ||
const isNotContentTypeHeader = (requestHasBody) => (header) => { | ||
return !requestHasBody ? 'content-type' != header.name.toLowerCase() : true; | ||
}; | ||
const isRelevantHeader = (header) => { | ||
const irrelevantHarHeaders = ['host', 'connection', 'content-length', 'pragma', 'cache-control', 'accept', | ||
'sec-fetch-dest', 'user-agent', 'origin', 'sec-fetch-site', 'sec-fetch-mode', , 'sec-fetch-user', 'referer', | ||
'accept-encoding', 'accept-language', 'cookie', 'upgrade-insecure-requests', ':scheme', ':authority', | ||
':method', ':path', 'api_key']; | ||
return !irrelevantHarHeaders.includes(header.name.toLowerCase()); | ||
}; | ||
const renameHeaderKey = (header) => { | ||
return {key: header.name, value: header.value}; | ||
}; | ||
const generateItemRequestBody = (requestBody) => { | ||
@@ -159,3 +156,4 @@ return { | ||
exec: exec, | ||
type: 'text/javascript'}; | ||
type: 'text/javascript', | ||
}; | ||
}; | ||
@@ -201,2 +199,6 @@ | ||
module.exports = HarToPostman; | ||
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') { | ||
module.exports = HarToPostman; | ||
} else { | ||
window.HarToPostman = HarToPostman; | ||
} |
{ | ||
"name": "har2postman", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"description": "Har to postman converter", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# Har2Postman | ||
[![npm version](https://badge.fury.io/js/har2postman.svg)](https://badge.fury.io/js/har2postman) | ||
Javascript Har to Postman converter. *THIS PROJECT IS RIGHT NOW UNDER HEAVY DEVELOPMENT* | ||
![Har2Postman](https://raw.githubusercontent.com/javieraviles/har2postman/master/docs/assets/img/logo.png) | ||
Javascript Har to Postman converter. [Try it out](https://javieraviles.github.io/Har2Postman/) | ||
## Purpose | ||
@@ -52,3 +54,3 @@ The main goal of the project is the creation of a JS library to convert `.har` files to Postman requests/collection in `.JSON` format. | ||
* The `createPostmanCollection` function should include a second optional `boolean` argument to decide whether the output should include the test section or not. By default, the behaviour of the boolean flag should be `false`. | ||
* Include basic usage example for the lib in docs | ||
* Include basic usage example for the lib in docs. | ||
@@ -60,7 +62,7 @@ ### v0.3.0 - GET request might include query params | ||
* CI pipeline should also include integration tests on tag release: using the just released version of the lib, generate a postman collection using the version input, and run it with newman so it checks the lib output works out of the box. | ||
* Include ESLint, with some format scripts in the package and check the linting from the pipeline too | ||
* Include ESLint, with some format scripts in the package and check the linting from the pipeline too. | ||
### v0.4.0 - Support multiple requests within one har file | ||
* A `har` file can contain multiple requests, and all them should be contained within the swagger collection | ||
* The provided examples contain api versioning; the lib should be able to deal with them | ||
* A `har` file can contain multiple requests, and all them should be contained within the swagger collection. | ||
* The provided examples contain api versioning; the lib should be able to deal with them. | ||
@@ -73,12 +75,15 @@ ### v0.5.0 - POST, PUT and DELETE methods should also be supported | ||
* Status code such as 200, 204, 400, 401, 403 or 404 must have specific assertions. | ||
* Non-json responses should even not tried to be analysed | ||
* Non-json responses should even not tried to be analysed. | ||
### v0.7.0 - Relevant headers should be included | ||
* Include relevant headers for each request, only the necessary ones. | ||
* Make library compatible for Browser. | ||
* Demo page automatically getting lib from cdn. | ||
### Future features still to be planned | ||
* Requests could include some way of authorization | ||
* Requests might include more useful headers | ||
* Url hostname of requests, if common, should come from an env variable | ||
* Auth methods should not be included as simple headers, but collection auth method and inherit from there in every request | ||
* support `xml` format | ||
* when creating an object, might be interesting to save it's `id` if contained in response as env variable for future requests over same entity (GET, PUT or DELETE) | ||
* Prepare nice docs | ||
* Make sure every function generates only one type of data structure. F.e. this should be avoided: | ||
@@ -85,0 +90,0 @@ |
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
221110
35
6097
135
8