Socket
Socket
Sign inDemoInstall

postman-url-encoder

Package Overview
Dependencies
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postman-url-encoder - npm Package Compare versions

Comparing version 3.0.2 to 3.0.3

2

package.json
{
"name": "postman-url-encoder",
"version": "3.0.2",
"version": "3.0.3",
"description": "Implementation of the WHATWG URL Standard",

@@ -5,0 +5,0 @@ "author": "Postman Inc.",

@@ -27,3 +27,5 @@ /**

REGEX_EXTRACT_VARS = /{{[^{}]*[.:/?#@&\]][^{}]*}}/g,
REGEX_ALL_BACKSLASHES = /\\/g,
REGEX_LEADING_SLASHES = /^\/+/,
REGEX_ALL_VARIABLES = /{{[^{}]*[.:/?#@&\]][^{}]*}}/g,

@@ -39,4 +41,6 @@ HASH_SEPARATOR = '#',

QUERY_SEGMENTS_SEPARATOR = '&',
PROTOCOL_SEPARATOR_WITH_BACKSLASH = ':\\\\',
E = '',
STRING = 'string',
FILE_PROTOCOL = 'file',
SAFE_REPLACE_CHAR = '_',

@@ -57,3 +61,3 @@ CLOSING_SQUARE_BRACKET = ']',

function normalizeVariables (str, replacements) {
let normalizedString = '',
let normalizedString = E,
pointer = 0, // pointer till witch the string is normalized

@@ -67,3 +71,3 @@ variable,

// ↑ (pointer = 0)
while ((match = REGEX_EXTRACT_VARS.exec(str)) !== null) {
while ((match = REGEX_ALL_VARIABLES.exec(str)) !== null) {
// {{user#name}}

@@ -161,2 +165,4 @@ variable = match[0];

pointer = 0,
protocol,
_length,
length,

@@ -167,3 +173,3 @@ index,

// bail out if input string is empty
if (!(urlString && typeof urlString === 'string')) {
if (!(urlString && typeof urlString === STRING)) {
return parsedUrl;

@@ -200,5 +206,8 @@ }

// 3. url.protocol
urlString = urlString.replace(REGEX_ALL_BACKSLASHES, PATH_SEPARATOR); // sanitize slashes
// @todo support `protocol:host/path` and `protocol:/host/path`
if ((index = urlString.indexOf(PROTOCOL_SEPARATOR)) !== -1) {
// extract from the front
url.protocol.value = urlString.slice(0, index);
url.protocol.value = protocol = urlString.slice(0, index);
url.protocol.beginIndex = pointer;

@@ -211,18 +220,17 @@ url.protocol.endIndex = pointer + index;

}
// protocol can be separated using :\\ as well
else if ((index = urlString.indexOf(PROTOCOL_SEPARATOR_WITH_BACKSLASH)) !== -1) {
// extract from the front
url.protocol.value = urlString.slice(0, index);
url.protocol.beginIndex = pointer;
url.protocol.endIndex = pointer + index;
urlString = urlString.slice(index + 3);
length -= index + 3;
pointer += index + 3;
}
// special handling for leading slashes e.g, http:///example.com
_length = length; // length with leading slashes
urlString = urlString.replace(REGEX_LEADING_SLASHES,
(protocol && protocol.toLowerCase() === FILE_PROTOCOL) ?
// file:////path -> file:///path
PATH_SEPARATOR :
// protocol:////host/path -> protocol://host/path
E);
length = urlString.length; // length without slashes
pointer += _length - length; // update pointer
// 4. url.path
urlString = urlString.replace(/\\/g, '/'); // sanitize path
urlString = urlString.replace(/^\/+/, ''); // remove leading slashes
if ((index = urlString.indexOf(PATH_SEPARATOR)) !== -1) {

@@ -229,0 +237,0 @@ // extract from the back

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc