Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fetch-har

Package Overview
Dependencies
Maintainers
9
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fetch-har - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

7

CHANGELOG.md

@@ -0,1 +1,8 @@

## <small>3.0.1 (2020-07-16)</small>
* fix: improved handling of application/x-www-form-urlencoded postData (#69) ([07b875b](https://github.com/readmeio/fetch-har/commit/07b875b)), closes [#69](https://github.com/readmeio/fetch-har/issues/69)
* build(deps-dev): bump nock from 13.0.0 to 13.0.2 (#68) ([20c0c8f](https://github.com/readmeio/fetch-har/commit/20c0c8f)), closes [#68](https://github.com/readmeio/fetch-har/issues/68)
## 3.0.0 (2020-06-30)

@@ -2,0 +9,0 @@

42

index.js

@@ -14,16 +14,34 @@ function constructRequest(har, userAgent = false) {

if (request.headers.length) {
options.headers = request.headers.map(header => headers.append(header.name, header.value));
}
if ('postData' in request) {
if ('params' in request.postData) {
const formBody = {};
request.postData.params.map(param => {
try {
formBody[param.name] = JSON.parse(param.value);
} catch (e) {
formBody[param.name] = param.value;
}
if ('mimeType' in request.postData && request.postData.mimeType === 'application/x-www-form-urlencoded') {
// Since the content we're handling here is to be encoded as application/x-www-form-urlencoded, this should
// override any other Content-Type headers that are present in the HAR. This is how Postman handles this case
// when building code snippets!
//
// https://github.com/github/fetch/issues/263#issuecomment-209530977
headers.set('Content-Type', request.postData.mimeType);
return true;
});
const encodedParams = new URLSearchParams();
request.postData.params.map(param => encodedParams.set(param.name, param.value));
options.body = JSON.stringify(formBody);
options.body = encodedParams;
} else {
const formBody = {};
request.postData.params.map(param => {
try {
formBody[param.name] = JSON.parse(param.value);
} catch (e) {
formBody[param.name] = param.value;
}
return true;
});
options.body = JSON.stringify(formBody);
}
} else {

@@ -34,6 +52,2 @@ options.body = request.postData.text;

if (request.headers.length) {
options.headers = request.headers.map(header => headers.append(header.name, header.value));
}
if (request.queryString.length) {

@@ -40,0 +54,0 @@ const query = request.queryString.map(q => `${q.name}=${q.value}`).join('&');

{
"name": "fetch-har",
"version": "3.0.0",
"version": "3.0.1",
"description": "Make a fetch request from a HAR file",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc