Comparing version 1.1.6 to 1.1.7
@@ -36,2 +36,7 @@ /** | ||
*/ | ||
export declare function parseQuery(input: string): Record<string, string>; | ||
export declare function parseQueryFromURL(input: string): Record<string, string>; | ||
/** | ||
* @callback parse | ||
* @param {string} input | ||
*/ | ||
export declare const parseQuery: (input: string) => Record<string, string[]>; |
@@ -33,3 +33,4 @@ "use strict"; | ||
__export(fast_querystring_exports, { | ||
parseQuery: () => parseQuery | ||
parseQuery: () => parseQuery, | ||
parseQueryFromURL: () => parseQueryFromURL | ||
}); | ||
@@ -39,3 +40,3 @@ module.exports = __toCommonJS(fast_querystring_exports); | ||
var plusRegex = /\+/g; | ||
function parseQuery(input) { | ||
function parseQueryFromURL(input) { | ||
const result = {}; | ||
@@ -111,5 +112,70 @@ if (typeof input !== "string") return result; | ||
} | ||
var parseQuery = (input) => { | ||
const result = {}; | ||
if (typeof input !== "string") return result; | ||
const inputLength = input.length; | ||
let key = ""; | ||
let value = ""; | ||
let startingIndex = -1; | ||
let equalityIndex = -1; | ||
let shouldDecodeKey = false; | ||
let shouldDecodeValue = false; | ||
let keyHasPlus = false; | ||
let valueHasPlus = false; | ||
let hasBothKeyValuePair = false; | ||
let c = 0; | ||
for (let i = 0; i < inputLength + 1; i++) { | ||
if (i !== inputLength) c = input.charCodeAt(i); | ||
else c = 38; | ||
switch (c) { | ||
case 38: { | ||
hasBothKeyValuePair = equalityIndex > startingIndex; | ||
if (!hasBothKeyValuePair) equalityIndex = i; | ||
key = input.slice(startingIndex + 1, equalityIndex); | ||
if (hasBothKeyValuePair || key.length > 0) { | ||
if (keyHasPlus) key = key.replace(plusRegex, " "); | ||
if (shouldDecodeKey) key = (0, import_fast_decode_uri_component.default)(key) || key; | ||
if (hasBothKeyValuePair) { | ||
value = input.slice(equalityIndex + 1, i); | ||
if (valueHasPlus) value = value.replace(plusRegex, " "); | ||
if (shouldDecodeValue) | ||
value = (0, import_fast_decode_uri_component.default)(value) || value; | ||
} | ||
const currentValue = result[key]; | ||
if (currentValue === void 0) | ||
result[key] = value; | ||
else { | ||
if (currentValue.pop) currentValue.push(value); | ||
else result[key] = [currentValue, value]; | ||
} | ||
} | ||
value = ""; | ||
startingIndex = i; | ||
equalityIndex = i; | ||
shouldDecodeKey = false; | ||
shouldDecodeValue = false; | ||
keyHasPlus = false; | ||
valueHasPlus = false; | ||
break; | ||
} | ||
case 61: | ||
if (equalityIndex <= startingIndex) equalityIndex = i; | ||
else shouldDecodeValue = true; | ||
break; | ||
case 43: | ||
if (equalityIndex > startingIndex) valueHasPlus = true; | ||
else keyHasPlus = true; | ||
break; | ||
case 37: | ||
if (equalityIndex > startingIndex) shouldDecodeValue = true; | ||
else shouldDecodeKey = true; | ||
break; | ||
} | ||
} | ||
return result; | ||
}; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
parseQuery | ||
parseQuery, | ||
parseQueryFromURL | ||
}); |
@@ -36,2 +36,7 @@ /** | ||
*/ | ||
export declare function parseQuery(input: string): Record<string, string>; | ||
export declare function parseQueryFromURL(input: string): Record<string, string>; | ||
/** | ||
* @callback parse | ||
* @param {string} input | ||
*/ | ||
export declare const parseQuery: (input: string) => Record<string, string[]>; |
{ | ||
"name": "elysia", | ||
"description": "Ergonomic Framework for Human", | ||
"version": "1.1.6", | ||
"version": "1.1.7", | ||
"author": { | ||
@@ -75,2 +75,7 @@ "name": "saltyAom", | ||
"require": "./dist/cjs/utils.js" | ||
}, | ||
"./fasti-querystring": { | ||
"types": "./dist/fast-querystring.d.ts", | ||
"import": "./dist/fast-querystring.mjs", | ||
"require": "./dist/cjs/fast-querystring.js" | ||
} | ||
@@ -77,0 +82,0 @@ }, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
2584471
55459