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

http-types

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-types - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

6

dist/index.js

@@ -78,3 +78,4 @@ "use strict";

this.headers.forEach(function (value, key) {
result[key] = value;
result[key] =
value instanceof Array && value.length == 1 ? value[0] : value;
});

@@ -130,3 +131,4 @@ return result;

this.parameters.forEach(function (value, key) {
result[key] = value;
result[key] =
value instanceof Array && value.length == 1 ? value[0] : value;
});

@@ -133,0 +135,0 @@ return result;

{
"name": "http-types",
"version": "0.3.0",
"version": "0.4.0",
"description": "Library for JSON serialisation of HTTP exchanges",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -80,3 +80,4 @@ /** HTTP request method to indicate the desired action to be performed for a given resource. */

this.headers.forEach(function(value, key) {
result[key] = value;
result[key] =
value instanceof Array && value.length == 1 ? value[0] : value;
});

@@ -138,3 +139,4 @@ return result;

this.parameters.forEach(function(value, key) {
result[key] = value;
result[key] =
value instanceof Array && value.length == 1 ? value[0] : value;
});

@@ -141,0 +143,0 @@ return result;

@@ -185,1 +185,35 @@ import {

});
test("Http exchanges from JSON with pathname and single query parameter as array", () => {
const json = `{
"request": {
"protocol": "https",
"host": "example.com",
"timestamp": "2018-11-13T20:20:39+02:00",
"method": "post",
"headers": {
"accept": "*/*",
"multi-value": ["value1", "value2"]
},
"pathname": "/a/path",
"query": {"a": ["b"]},
"body": "a request body"
},
"response": {
"timestamp": "2019-11-13T20:20:39+02:00",
"statusCode": 404,
"headers": {
"content-length": "15",
"Upper-Case": "yes"
},
"body": "a response body"
}
}`;
const exchange = HttpExchangeReader.fromJson(json);
expect(exchange.request.pathname).toBe("/a/path");
expect(exchange.request.query.get("a")).toBe("b");
console.log("AAAA " + JSON.stringify(exchange));
expect(JSON.parse(JSON.stringify(exchange))["request"]["query"]["a"]).toBe(
"b"
);
});

Sorry, the diff of this file is not supported yet

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