Socket
Socket
Sign inDemoInstall

postman-collection

Package Overview
Dependencies
Maintainers
5
Versions
180
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postman-collection - npm Package Compare versions

Comparing version 3.6.0-beta.3 to 3.6.0

89

lib/collection/query-param.js

@@ -14,9 +14,92 @@ var _ = require('../util').lodash,

EMPTY = '',
HASH = '#',
BRACE_START = '{{',
BRACE_END = '}}',
REGEX_HASH = /#/g,
REGEX_EQUALS = /=/g, // eslint-disable-line no-div-regex
REGEX_AMPERSAND = /&/g,
REGEX_BRACE_START = /%7B%7B/g,
REGEX_BRACE_END = /%7D%7D/g,
REGEX_EXTRACT_VARS = /{{[^{}]*[&#=][^{}]*}}/g,
QueryParam;
QueryParam,
/**
* Percent encode reserved chars (&, = and #) in the given string.
*
* @private
* @param {String} str
* @param {Boolean} encodeEquals
* @returns {String}
*/
encodeReservedChars = function (str, encodeEquals) {
if (!str) {
return str;
}
// eslint-disable-next-line lodash/prefer-includes
str.indexOf(AMPERSAND) !== -1 && (str = str.replace(REGEX_AMPERSAND, '%26'));
// eslint-disable-next-line lodash/prefer-includes
str.indexOf(HASH) !== -1 && (str = str.replace(REGEX_HASH, '%23'));
// eslint-disable-next-line lodash/prefer-includes
encodeEquals && str.indexOf(EQUALS) !== -1 && (str = str.replace(REGEX_EQUALS, '%3D'));
return str;
},
/**
* Normalize the given param string by percent-encoding the reserved chars
* such that it won't affect the re-parsing.
*
* @note `&`, `=` and `#` needs to be percent-encoded otherwise re-parsing
* the same URL string will generate different output
*
* @private
* @param {String} str
* @param {Boolean} encodeEquals
* @returns {String}
*/
normalizeParam = function (str, encodeEquals) {
// bail out if the given sting is null or empty
if (!(str && typeof str === STRING)) {
return str;
}
// bail out if the given string does not include reserved chars
// eslint-disable-next-line lodash/prefer-includes
if (str.indexOf(AMPERSAND) === -1 && str.indexOf(HASH) === -1) {
// eslint-disable-next-line lodash/prefer-includes
if (!(encodeEquals && str.indexOf(EQUALS) !== -1)) {
return str;
}
}
var normalizedString = '',
pointer = 0,
variable,
match,
index;
// find all the instances of {{<variable>}} which includes reserved chars
while ((match = REGEX_EXTRACT_VARS.exec(str)) !== null) {
variable = match[0];
index = match.index;
// [pointer, index) string is normalized + the matched variable
normalizedString += encodeReservedChars(str.slice(pointer, index), encodeEquals) + variable;
// update the pointer
pointer = index + variable.length;
}
// whatever left in the string is normalized as well
if (pointer < str.length) {
normalizedString += encodeReservedChars(str.slice(pointer), encodeEquals);
}
return normalizedString;
};
/**

@@ -211,3 +294,3 @@ * @typedef QueryParam~definition

if (typeof key === STRING) {
result = encode ? encodeQueryParam(key) : key;
result = encode ? encodeQueryParam(key) : normalizeParam(key, true);
}

@@ -219,3 +302,3 @@ else {

if (typeof value === STRING) {
result += EQUALS + (encode ? encodeQueryParam(value) : value);
result += EQUALS + (encode ? encodeQueryParam(value) : normalizeParam(value));
}

@@ -222,0 +305,0 @@

4

package.json

@@ -5,3 +5,3 @@ {

"author": "Postman Labs <help@getpostman.com>",
"version": "3.6.0-beta.3",
"version": "3.6.0",
"keywords": [

@@ -77,3 +77,3 @@ "postman"

"postman-jsdoc-theme": "0.0.3",
"postman-request": "2.88.1-postman.18",
"postman-request": "2.88.1-postman.19",
"puppeteer": "1.20.0",

@@ -80,0 +80,0 @@ "recursive-readdir": "2.2.2",

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