feat: ✨ Created a mini nodeJS server with NewMan for testing without PostMan GUI.
This will mimic a run in a CD/CI environment or docker container.
This commit is contained in:
65
node_modules/liquid-json/lib/bomb.js
generated
vendored
Normal file
65
node_modules/liquid-json/lib/bomb.js
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
var bomb = {
|
||||
/**
|
||||
* @private
|
||||
* @type {Object}
|
||||
*/
|
||||
code: { // @todo: could be shifted to outside the bomb object
|
||||
FEFF: 0xFEFF,
|
||||
BBBF: 0xBBBF,
|
||||
FE: 0xFE,
|
||||
FF: 0xFF,
|
||||
EF: 0xEF,
|
||||
BB: 0xBB,
|
||||
BF: 0xBF
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks whether string has BOM
|
||||
* @param {String} str An input string that is tested for the presence of BOM
|
||||
*
|
||||
* @returns {Number} If greater than 0, implies that a BOM of returned length was found. Else, zero is returned.
|
||||
*/
|
||||
indexOfBOM: function (str) {
|
||||
if (typeof str !== 'string') {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// @todo: compress logic below
|
||||
// remove UTF-16 and UTF-32 BOM (https://en.wikipedia.org/wiki/Byte_order_mark#UTF-8)
|
||||
if ((str.charCodeAt(0) === bomb.code.FEFF) || (str.charCodeAt(0) === bomb.code.BBBF)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// big endian UTF-16 BOM
|
||||
if ((str.charCodeAt(0) === bomb.code.FE) && (str.charCodeAt(1) === bomb.code.FF)) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
// little endian UTF-16 BOM
|
||||
if ((str.charCodeAt(0) === bomb.code.FF) && (str.charCodeAt(1) === bomb.code.FE)) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
// UTF-8 BOM
|
||||
if ((str.charCodeAt(0) === bomb.code.EF) && (str.charCodeAt(1) === bomb.code.BB) &&
|
||||
(str.charCodeAt(2) === bomb.code.BF)) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
return 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* Trim BOM from a string
|
||||
*
|
||||
* @param {String} str An input string that is tested for the presence of BOM
|
||||
* @returns {String} The input string stripped of any BOM, if found. If the input is not a string, it is returned as
|
||||
* is.
|
||||
*/
|
||||
trim: function (str) {
|
||||
var pos = bomb.indexOfBOM(str);
|
||||
return pos ? str.slice(pos) : str;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = bomb;
|
78
node_modules/liquid-json/lib/index.js
generated
vendored
Normal file
78
node_modules/liquid-json/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
/**!
|
||||
* Originally written by:
|
||||
* https://github.com/sindresorhus/parse-json
|
||||
*/
|
||||
var fallback = require('../vendor/parse'),
|
||||
bomb = require('./bomb'),
|
||||
FALLBACK_MODE = 'json',
|
||||
ERROR_NAME = 'JSONError',
|
||||
|
||||
parse; // fn
|
||||
|
||||
/**
|
||||
* Accept a string as JSON and return an object.
|
||||
* @private
|
||||
*
|
||||
* @param {String} str The input stringified JSON object to be parsed.
|
||||
* @param {Function=} [reviver] A customizer function to be used within the fallback (BOM friendly) JSON parser.
|
||||
* @param {Boolean=} [strict] Set to true to treat the occurrence of BOM as a fatal error.
|
||||
*
|
||||
* @returns {Object} The parsed JSON object constructed from str
|
||||
* @throws {SyntaxError} If `str` is not a valid JSON
|
||||
* @throws {SyntaxError} In `strict` mode if `str` contains BOM
|
||||
*/
|
||||
parse = function (str, reviver, strict) {
|
||||
var bomMarkerIndex = bomb.indexOfBOM(str);
|
||||
|
||||
if (bomMarkerIndex) {
|
||||
if (strict) {
|
||||
throw SyntaxError('Unexpected byte order mark found in first ' + bomMarkerIndex + ' character(s)');
|
||||
}
|
||||
// clean up BOM if not strict
|
||||
str = str.slice(bomMarkerIndex);
|
||||
}
|
||||
|
||||
try { // first try and use normal JSON.parse as this is faster
|
||||
return JSON.parse(str, reviver);
|
||||
}
|
||||
catch (err) { // if JSON.parse fails, we try using a more verbose parser
|
||||
fallback.parse(str, {
|
||||
mode: FALLBACK_MODE,
|
||||
reviver: reviver
|
||||
});
|
||||
|
||||
// if there was an error in this catch block, `fallback.parse` should raise same error. hence this `throw`
|
||||
// will never get executed. if it does not, we still throw original error.
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
parse: function (str, reviver, relaxed) {
|
||||
if ((typeof reviver === 'boolean') && (relaxed === null)) {
|
||||
relaxed = reviver;
|
||||
reviver = null;
|
||||
}
|
||||
|
||||
try {
|
||||
return parse(str, reviver, relaxed);
|
||||
}
|
||||
// we do this simply to set the error name and as such making it more identifiable
|
||||
catch (err) {
|
||||
err.name = ERROR_NAME;
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
|
||||
stringify: function () {
|
||||
try {
|
||||
// eslint-disable-next-line prefer-spread
|
||||
return JSON.stringify.apply(JSON, arguments);
|
||||
}
|
||||
// we do this simply to set the error name and as such making it more identifiable
|
||||
catch (err) {
|
||||
err.name = ERROR_NAME;
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user