mirror of
https://github.com/github/codeql-action.git
synced 2025-12-26 09:10:07 +08:00
* Bump tough-cookie and @azure/ms-rest-js Bumps [tough-cookie](https://github.com/salesforce/tough-cookie) and [@azure/ms-rest-js](https://github.com/Azure/ms-rest-js). These dependencies needed to be updated together. Updates `tough-cookie` from 4.0.0 to 4.1.3 - [Release notes](https://github.com/salesforce/tough-cookie/releases) - [Changelog](https://github.com/salesforce/tough-cookie/blob/master/CHANGELOG.md) - [Commits](https://github.com/salesforce/tough-cookie/compare/v4.0.0...v4.1.3) Updates `@azure/ms-rest-js` from 2.6.2 to 2.7.0 - [Changelog](https://github.com/Azure/ms-rest-js/blob/master/Changelog.md) - [Commits](https://github.com/Azure/ms-rest-js/commits) --- updated-dependencies: - dependency-name: tough-cookie dependency-type: indirect - dependency-name: "@azure/ms-rest-js" dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Update checked-in dependencies --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
119 lines
2.5 KiB
JavaScript
119 lines
2.5 KiB
JavaScript
'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;
|