feat: update dependencies, node
This commit is contained in:
+22
@@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Unshift.io, Arnout Kazemier, the Contributors.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
+61
File diff suppressed because one or more lines are too long
+118
@@ -0,0 +1,118 @@
|
||||
'use strict';
|
||||
|
||||
var has = Object.prototype.hasOwnProperty
|
||||
, undef;
|
||||
|
||||
/**
|
||||
* Decode a URI encoded string.
|
||||
*
|
||||
* @param {String} input The URI encoded string.
|
||||
* @returns {String|Null} The decoded string.
|
||||
* @api private
|
||||
*/
|
||||
function decode(input) {
|
||||
try {
|
||||
return decodeURIComponent(input.replace(/\+/g, ' '));
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to encode a given input.
|
||||
*
|
||||
* @param {String} input The string that needs to be encoded.
|
||||
* @returns {String|Null} The encoded string.
|
||||
* @api private
|
||||
*/
|
||||
function encode(input) {
|
||||
try {
|
||||
return encodeURIComponent(input);
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple query string parser.
|
||||
*
|
||||
* @param {String} query The query string that needs to be parsed.
|
||||
* @returns {Object}
|
||||
* @api public
|
||||
*/
|
||||
function querystring(query) {
|
||||
var parser = /([^=?#&]+)=?([^&]*)/g
|
||||
, result = {}
|
||||
, part;
|
||||
|
||||
while (part = parser.exec(query)) {
|
||||
var key = decode(part[1])
|
||||
, value = decode(part[2]);
|
||||
|
||||
//
|
||||
// Prevent overriding of existing properties. This ensures that build-in
|
||||
// methods like `toString` or __proto__ are not overriden by malicious
|
||||
// querystrings.
|
||||
//
|
||||
// In the case if failed decoding, we want to omit the key/value pairs
|
||||
// from the result.
|
||||
//
|
||||
if (key === null || value === null || key in result) continue;
|
||||
result[key] = value;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform a query string to an object.
|
||||
*
|
||||
* @param {Object} obj Object that should be transformed.
|
||||
* @param {String} prefix Optional prefix.
|
||||
* @returns {String}
|
||||
* @api public
|
||||
*/
|
||||
function querystringify(obj, prefix) {
|
||||
prefix = prefix || '';
|
||||
|
||||
var pairs = []
|
||||
, value
|
||||
, key;
|
||||
|
||||
//
|
||||
// Optionally prefix with a '?' if needed
|
||||
//
|
||||
if ('string' !== typeof prefix) prefix = '?';
|
||||
|
||||
for (key in obj) {
|
||||
if (has.call(obj, key)) {
|
||||
value = obj[key];
|
||||
|
||||
//
|
||||
// Edge cases where we actually want to encode the value to an empty
|
||||
// string instead of the stringified value.
|
||||
//
|
||||
if (!value && (value === null || value === undef || isNaN(value))) {
|
||||
value = '';
|
||||
}
|
||||
|
||||
key = encode(key);
|
||||
value = encode(value);
|
||||
|
||||
//
|
||||
// If we failed to encode the strings, we should bail out as we don't
|
||||
// want to add invalid strings to the query.
|
||||
//
|
||||
if (key === null || value === null) continue;
|
||||
pairs.push(key +'='+ value);
|
||||
}
|
||||
}
|
||||
|
||||
return pairs.length ? prefix + pairs.join('&') : '';
|
||||
}
|
||||
|
||||
//
|
||||
// Expose the module.
|
||||
//
|
||||
exports.stringify = querystringify;
|
||||
exports.parse = querystring;
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "querystringify",
|
||||
"version": "2.2.0",
|
||||
"description": "Querystringify - Small, simple but powerful query string parser.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "nyc --reporter=html --reporter=text mocha test.js",
|
||||
"watch": "mocha --watch test.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/unshiftio/querystringify"
|
||||
},
|
||||
"keywords": [
|
||||
"query",
|
||||
"string",
|
||||
"query-string",
|
||||
"querystring",
|
||||
"qs",
|
||||
"stringify",
|
||||
"parse",
|
||||
"decode",
|
||||
"encode"
|
||||
],
|
||||
"author": "Arnout Kazemier",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/unshiftio/querystringify/issues"
|
||||
},
|
||||
"homepage": "https://github.com/unshiftio/querystringify",
|
||||
"devDependencies": {
|
||||
"assume": "^2.1.0",
|
||||
"coveralls": "^3.1.0",
|
||||
"mocha": "^8.1.1",
|
||||
"nyc": "^15.1.0",
|
||||
"pre-commit": "^1.2.2"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user