first commit

This commit is contained in:
armansansd
2023-07-12 16:31:19 +01:00
commit 3424b1927b
23306 changed files with 2217776 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
var querystring = require("querystring");
for(var i in querystring){
exports[i] = querystring[i];
}
var type = Function.prototype.call.bind(Object.prototype.toString);
// Parse the name/value pairs of the query string into a flattened array
// Automatically munge the parameters
exports.parseToArray = function(arr, qs){
var parsed = exports.parse(qs);
for(var i in parsed){
exports.addToArray(arr, i, parsed[i]);
}
};
// Add munged values with name/value pairs to the flattened array
exports.addToArray = function(arr, name, value){
if(value === undefined || value === null){
value = "";
}
switch(type(value)){
case "[object String]":
case "[object Number]":
case "[object Boolean]":
arr.push(name, value + "");
break;
case "[object Array]":
value.forEach(function(value){
exports.addToArray(arr, name + "[]", value);
});
break;
case "[object Object]":
for(var k in value){
exports.addToArray(arr, name + "[" + k + "]", value[k]);
}
};
};
+38
View File
@@ -0,0 +1,38 @@
// Adapted from the following:
//
// Original License
// ----------------
// parseUri 1.2.2
// (c) Steven Levithan <stevenlevithan.com>
// MIT License
function parseUri (str) {
var o = parseUri.options,
m = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
uri = {},
i = 14;
while (i--) uri[o.key[i]] = m[i] || "";
uri[o.q.name] = {};
uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
if ($1) uri[o.q.name][$1] = $2;
});
return uri;
};
parseUri.options = {
strictMode: false,
key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
q: {
name: "queryKey",
parser: /(?:^|&)([^&=]*)=?([^&]*)/g
},
parser: {
strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
}
};
exports.parseUri = parseUri;