This repository has been archived on 2022-06-10. You can view files and clone it, but cannot push or open issues or pull requests.
mydraftcc-nodejs-server/server/lib/Libsecurity.js

37 lines
724 B
JavaScript
Raw Normal View History

2022-06-04 18:04:25 +00:00
"use strict";
class Libsecurity {
/**
*
* @param {object} obj
* @param {number} maxsize
* @returns
*/
static jsonSizeIsAcceptable(obj, maxsize) {
const size = JSON.stringify(obj).length;
if (typeof obj === "object" && size > maxsize)
throw new Error(
"Warning Date received exceed defined max size - Libsecurity",
"size received:",
obj.length,
"acceptable",
size
);
return true;
}
/**
*
* @param {string} str - filename to sanitize
* @returns
*/
static sanitizeFileName(str) {
return str
.replace(/(.*\/)|(\/.*)/g, "")
.replace(/\.\./g, "")
.replace(/;/g, "");
}
}
module.exports = Libsecurity;