New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

isomorphic-querystring

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

isomorphic-querystring - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

README.md

174

browser.js

@@ -1,94 +0,100 @@

const querystring = {
unescape: window.decodeURIComponent,
escape: window.encodeURIComponent,
stringify: function stringify(
obj,
sep = "&",
eq = "=",
{ encodeURIComponent = querystring.escape } = {}
) {
return Object.entries(obj)
.reduce((result, [key, value]) => {
switch (typeof value) {
case "boolean":
case "number":
case "string":
function stringify(
obj,
sep = "&",
eq = "=",
{ encodeURIComponent = window.encodeURIComponent } = {}
) {
return Object.entries(obj)
.reduce((result, [key, value]) => {
switch (typeof value) {
case "boolean":
case "number":
case "string":
return result.concat(
`${encodeURIComponent(key)}${eq}${encodeURIComponent(value)}`
);
case "object":
if (Array.isArray(value)) {
return result.concat(
`${encodeURIComponent(key)}${eq}${encodeURIComponent(value)}`
value.map(
v => `${encodeURIComponent(key)}${eq}${encodeURIComponent(v)}`
)
);
case "object":
if (Array.isArray(value)) {
return result.concat(
value.map(
v => `${encodeURIComponent(key)}${eq}${encodeURIComponent(v)}`
)
);
}
default:
return result.concat(`${encodeURIComponent(key)}${eq}`);
}
}, [])
.join(sep);
},
parse: function parse(
str,
sep = "&",
eq = "=",
{ decodeURIComponent = querystring.unescape, maxKeys = 1000 } = {}
) {
const result = Object.create(null);
const length = str.length;
let key = "";
let keyOrValue = 0;
let parsedKeys = 0;
let value = "";
for (let i = 0; i <= length; i++) {
if (parsedKeys >= maxKeys) {
break;
}
default:
return result.concat(`${encodeURIComponent(key)}${eq}`);
}
}, [])
.join(sep);
}
const char = str[i];
function parse(
str,
sep = "&",
eq = "=",
{ decodeURIComponent = window.decodeURIComponent, maxKeys = 1000 } = {}
) {
const result = Object.create(null);
const length = str.length;
let key = "";
let keyOrValue = 0;
let parsedKeys = 0;
let value = "";
switch (char) {
case undefined:
case eq:
if (!(decodeURIComponent(key) in result)) {
result[decodeURIComponent(key)] = undefined;
}
parsedKeys += 1;
keyOrValue = 1;
break;
case sep:
if (Array.isArray(result[decodeURIComponent(key)])) {
// concat array
result[decodeURIComponent(key)].concat(decodeURIComponent(value));
} else if (result[decodeURIComponent(key)] !== undefined) {
// turn into array
result[decodeURIComponent(key)] = [
result[decodeURIComponent(key)]
].concat(decodeURIComponent(value));
} else {
// set value
result[decodeURIComponent(key)] = decodeURIComponent(value);
}
for (let i = 0; i <= length; i++) {
if (parsedKeys >= maxKeys) {
break;
}
key = "";
value = "";
keyOrValue = 0;
break;
default:
if (keyOrValue === 1) {
value += char;
} else {
key += char;
}
break;
}
const char = str[i];
switch (char) {
case undefined:
case eq:
if (!(decodeURIComponent(key) in result)) {
result[decodeURIComponent(key)] = undefined;
}
parsedKeys += 1;
keyOrValue = 1;
break;
case sep:
if (Array.isArray(result[decodeURIComponent(key)])) {
// concat array
result[decodeURIComponent(key)].concat(decodeURIComponent(value));
} else if (result[decodeURIComponent(key)] !== undefined) {
// turn into array
result[decodeURIComponent(key)] = [
result[decodeURIComponent(key)]
].concat(decodeURIComponent(value));
} else {
// set value
result[decodeURIComponent(key)] = decodeURIComponent(value);
}
key = "";
value = "";
keyOrValue = 0;
break;
default:
if (keyOrValue === 1) {
value += char;
} else {
key += char;
}
break;
}
}
return result;
}
return result;
}
const querystring = {
decode: parse,
encode: stringify,
escape: window.encodeURIComponent,
parse,
stringify,
unescape: window.decodeURIComponent
};
module.exports = window.querystring = querystring;
module.exports = querystring;
{
"name": "isomorphic-querystring",
"version": "1.0.0",
"version": "1.1.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "description": "isomorphic querystring interface for client & server.",

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