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

vscode-uri

Package Overview
Dependencies
Maintainers
3
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vscode-uri - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

112

lib/esm/index.js

@@ -107,14 +107,2 @@ /*---------------------------------------------------------------------------------------------

var _regexp = /^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;
function _isQueryStringScheme(scheme) {
if (!scheme) {
return false;
}
switch (scheme.toLowerCase()) {
case 'http':
case 'https':
case 'ftp':
return true;
}
return false;
}
/**

@@ -266,5 +254,5 @@ * Uniform Resource Identifier (URI) http://tools.ietf.org/html/rfc3986.

if (!match) {
return new _URI(_empty, _empty, _empty, _empty, _empty, _strict);
return new _URI(_empty, _empty, _empty, _empty, _empty);
}
return new _URI(match[2] || _empty, decodeURIComponentFast(match[4] || _empty, false, false), decodeURIComponentFast(match[5] || _empty, true, false), decodeURIComponentFast(match[7] || _empty, false, _isQueryStringScheme(match[2])), decodeURIComponentFast(match[9] || _empty, false, false), _strict);
return new _URI(match[2] || _empty, decodeURIComponent(match[4] || _empty), decodeURIComponent(match[5] || _empty), decodeURIComponent(match[7] || _empty), decodeURIComponent(match[9] || _empty), _strict);
};

@@ -296,3 +284,3 @@ /**

// on other systems bwd-slashes are valid
// filename character, e.g. /f\oo/ba\r.txt
// filename character, eg /f\oo/ba\r.txt
if (isWindows) {

@@ -420,61 +408,2 @@ path = path.replace(/\\/g, _slash);

}(URI));
function isHex(value, pos) {
if (pos >= value.length) {
return false;
}
var code = value.charCodeAt(pos);
return (code >= 48 /* Digit0 */ && code <= 57 /* Digit9 */) // 0-9
|| (code >= 97 /* a */ && code <= 102 /* f */) //a-f
|| (code >= 65 /* A */ && code <= 70 /* F */); //A-F
}
function decodeURIComponentFast(uriComponent, isPath, isQueryString) {
var res;
var nativeDecodePos = -1;
for (var pos = 0; pos < uriComponent.length; pos++) {
var code = uriComponent.charCodeAt(pos);
// decoding needed
if (code === 37 /* PercentSign */ && isHex(uriComponent, pos + 1) && isHex(uriComponent, pos + 2)) {
var chA = uriComponent.charCodeAt(pos + 1);
var chB = uriComponent.charCodeAt(pos + 2);
// when in a path -> check and accept %2f and %2F (fwd slash)
// when in a query string -> check and accept %3D, %26, and %3B (equals, ampersand, semi-colon)
if ((isPath && chA === 50 /* Digit2 */ && (chB === 70 /* F */ || chB === 102 /* f */))
||
(isQueryString && ((chA === 50 /* Digit2 */ && chB === 54 /* Digit6 */) // %26
||
(chA === 51 /* Digit3 */ && (chB === 66 /* B */ || chB === 98 /* b */ || chB === 68 /* D */ || chB === 100 /* d */)) // %3D, %3D
))) {
if (nativeDecodePos !== -1) {
res += decodeURIComponent(uriComponent.substring(nativeDecodePos, pos));
nativeDecodePos = -1;
}
if (res !== undefined) {
res += uriComponent.substr(pos, 3);
}
pos += 2;
continue;
}
if (res === undefined) {
res = uriComponent.substring(0, pos);
}
if (nativeDecodePos === -1) {
nativeDecodePos = pos;
}
pos += 2;
}
else {
if (nativeDecodePos !== -1) {
res += decodeURIComponent(uriComponent.substring(nativeDecodePos, pos));
nativeDecodePos = -1;
}
if (res !== undefined) {
res += String.fromCharCode(code);
}
}
}
if (nativeDecodePos !== -1) {
res += decodeURIComponent(uriComponent.substr(nativeDecodePos));
}
return res !== undefined ? res : uriComponent;
}
// reserved characters: https://tools.ietf.org/html/rfc3986#section-2.2

@@ -502,3 +431,3 @@ var encodeTable = (_a = {},

_a);
function encodeURIComponentFast(uriComponent, isPath, isQueryString) {
function encodeURIComponentFast(uriComponent, allowSlash) {
var res = undefined;

@@ -516,5 +445,3 @@ var nativeEncodePos = -1;

|| code === 126 /* Tilde */
|| (isPath && code === 47 /* Slash */) // path => allow slash AS-IS
|| (isQueryString && (code === 61 /* Equals */ || code === 38 /* Ampersand */ || code === 59 /* Semicolon */)) // query string => allow &=;
) {
|| (allowSlash && code === 47 /* Slash */)) {
// check if we are delaying native encode

@@ -530,15 +457,2 @@ if (nativeEncodePos !== -1) {

}
else if (code === 37 /* PercentSign */ && isHex(uriComponent, pos + 1) && isHex(uriComponent, pos + 2)) {
// at percentage encoded value
// check if we are delaying native encode
if (nativeEncodePos !== -1) {
res += encodeURIComponent(uriComponent.substring(nativeEncodePos, pos));
nativeEncodePos = -1;
}
// check if we write into a new string (by default we try to return the param)
if (res !== undefined) {
res += uriComponent.substr(pos, 3);
}
pos += 2;
}
else {

@@ -638,9 +552,9 @@ // encoding needed, we need to allocate a new string

if (idx === -1) {
res += encoder(userinfo, false, false);
res += encoder(userinfo, false);
}
else {
// <user>:<pass>@<auth>
res += encoder(userinfo.substr(0, idx), false, false);
res += encoder(userinfo.substr(0, idx), false);
res += ':';
res += encoder(userinfo.substr(idx + 1), false, false);
res += encoder(userinfo.substr(idx + 1), false);
}

@@ -652,7 +566,7 @@ res += '@';

if (idx === -1) {
res += encoder(authority, false, false);
res += encoder(authority, false);
}
else {
// <auth>:<port>
res += encoder(authority.substr(0, idx), false, false);
res += encoder(authority.substr(0, idx), false);
res += authority.substr(idx);

@@ -676,11 +590,11 @@ }

// encode the rest of the path
res += encoder(path, true, false);
res += encoder(path, true);
}
if (query) {
res += '?';
res += encoder(query, false, _isQueryStringScheme(scheme));
res += encoder(query, false);
}
if (fragment) {
res += '#';
res += !skipEncoding ? encodeURIComponentFast(fragment, false, false) : fragment;
res += !skipEncoding ? encodeURIComponentFast(fragment, false) : fragment;
}

@@ -687,0 +601,0 @@ return res;

@@ -118,14 +118,2 @@ var __extends = (this && this.__extends) || (function () {

var _regexp = /^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;
function _isQueryStringScheme(scheme) {
if (!scheme) {
return false;
}
switch (scheme.toLowerCase()) {
case 'http':
case 'https':
case 'ftp':
return true;
}
return false;
}
/**

@@ -277,5 +265,5 @@ * Uniform Resource Identifier (URI) http://tools.ietf.org/html/rfc3986.

if (!match) {
return new _URI(_empty, _empty, _empty, _empty, _empty, _strict);
return new _URI(_empty, _empty, _empty, _empty, _empty);
}
return new _URI(match[2] || _empty, decodeURIComponentFast(match[4] || _empty, false, false), decodeURIComponentFast(match[5] || _empty, true, false), decodeURIComponentFast(match[7] || _empty, false, _isQueryStringScheme(match[2])), decodeURIComponentFast(match[9] || _empty, false, false), _strict);
return new _URI(match[2] || _empty, decodeURIComponent(match[4] || _empty), decodeURIComponent(match[5] || _empty), decodeURIComponent(match[7] || _empty), decodeURIComponent(match[9] || _empty), _strict);
};

@@ -307,3 +295,3 @@ /**

// on other systems bwd-slashes are valid
// filename character, e.g. /f\oo/ba\r.txt
// filename character, eg /f\oo/ba\r.txt
if (isWindows) {

@@ -431,61 +419,2 @@ path = path.replace(/\\/g, _slash);

}(URI));
function isHex(value, pos) {
if (pos >= value.length) {
return false;
}
var code = value.charCodeAt(pos);
return (code >= 48 /* Digit0 */ && code <= 57 /* Digit9 */) // 0-9
|| (code >= 97 /* a */ && code <= 102 /* f */) //a-f
|| (code >= 65 /* A */ && code <= 70 /* F */); //A-F
}
function decodeURIComponentFast(uriComponent, isPath, isQueryString) {
var res;
var nativeDecodePos = -1;
for (var pos = 0; pos < uriComponent.length; pos++) {
var code = uriComponent.charCodeAt(pos);
// decoding needed
if (code === 37 /* PercentSign */ && isHex(uriComponent, pos + 1) && isHex(uriComponent, pos + 2)) {
var chA = uriComponent.charCodeAt(pos + 1);
var chB = uriComponent.charCodeAt(pos + 2);
// when in a path -> check and accept %2f and %2F (fwd slash)
// when in a query string -> check and accept %3D, %26, and %3B (equals, ampersand, semi-colon)
if ((isPath && chA === 50 /* Digit2 */ && (chB === 70 /* F */ || chB === 102 /* f */))
||
(isQueryString && ((chA === 50 /* Digit2 */ && chB === 54 /* Digit6 */) // %26
||
(chA === 51 /* Digit3 */ && (chB === 66 /* B */ || chB === 98 /* b */ || chB === 68 /* D */ || chB === 100 /* d */)) // %3D, %3D
))) {
if (nativeDecodePos !== -1) {
res += decodeURIComponent(uriComponent.substring(nativeDecodePos, pos));
nativeDecodePos = -1;
}
if (res !== undefined) {
res += uriComponent.substr(pos, 3);
}
pos += 2;
continue;
}
if (res === undefined) {
res = uriComponent.substring(0, pos);
}
if (nativeDecodePos === -1) {
nativeDecodePos = pos;
}
pos += 2;
}
else {
if (nativeDecodePos !== -1) {
res += decodeURIComponent(uriComponent.substring(nativeDecodePos, pos));
nativeDecodePos = -1;
}
if (res !== undefined) {
res += String.fromCharCode(code);
}
}
}
if (nativeDecodePos !== -1) {
res += decodeURIComponent(uriComponent.substr(nativeDecodePos));
}
return res !== undefined ? res : uriComponent;
}
// reserved characters: https://tools.ietf.org/html/rfc3986#section-2.2

@@ -513,3 +442,3 @@ var encodeTable = (_a = {},

_a);
function encodeURIComponentFast(uriComponent, isPath, isQueryString) {
function encodeURIComponentFast(uriComponent, allowSlash) {
var res = undefined;

@@ -527,5 +456,3 @@ var nativeEncodePos = -1;

|| code === 126 /* Tilde */
|| (isPath && code === 47 /* Slash */) // path => allow slash AS-IS
|| (isQueryString && (code === 61 /* Equals */ || code === 38 /* Ampersand */ || code === 59 /* Semicolon */)) // query string => allow &=;
) {
|| (allowSlash && code === 47 /* Slash */)) {
// check if we are delaying native encode

@@ -541,15 +468,2 @@ if (nativeEncodePos !== -1) {

}
else if (code === 37 /* PercentSign */ && isHex(uriComponent, pos + 1) && isHex(uriComponent, pos + 2)) {
// at percentage encoded value
// check if we are delaying native encode
if (nativeEncodePos !== -1) {
res += encodeURIComponent(uriComponent.substring(nativeEncodePos, pos));
nativeEncodePos = -1;
}
// check if we write into a new string (by default we try to return the param)
if (res !== undefined) {
res += uriComponent.substr(pos, 3);
}
pos += 2;
}
else {

@@ -649,9 +563,9 @@ // encoding needed, we need to allocate a new string

if (idx === -1) {
res += encoder(userinfo, false, false);
res += encoder(userinfo, false);
}
else {
// <user>:<pass>@<auth>
res += encoder(userinfo.substr(0, idx), false, false);
res += encoder(userinfo.substr(0, idx), false);
res += ':';
res += encoder(userinfo.substr(idx + 1), false, false);
res += encoder(userinfo.substr(idx + 1), false);
}

@@ -663,7 +577,7 @@ res += '@';

if (idx === -1) {
res += encoder(authority, false, false);
res += encoder(authority, false);
}
else {
// <auth>:<port>
res += encoder(authority.substr(0, idx), false, false);
res += encoder(authority.substr(0, idx), false);
res += authority.substr(idx);

@@ -687,11 +601,11 @@ }

// encode the rest of the path
res += encoder(path, true, false);
res += encoder(path, true);
}
if (query) {
res += '?';
res += encoder(query, false, _isQueryStringScheme(scheme));
res += encoder(query, false);
}
if (fragment) {
res += '#';
res += !skipEncoding ? encodeURIComponentFast(fragment, false, false) : fragment;
res += !skipEncoding ? encodeURIComponentFast(fragment, false) : fragment;
}

@@ -698,0 +612,0 @@ return res;

2

package.json
{
"name": "vscode-uri",
"author": "Microsoft",
"version": "2.0.2",
"version": "2.0.3",
"description": "The URI implementation that is used by VS Code and its extensions",

@@ -6,0 +6,0 @@ "main": "./lib/umd/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