Files
notes-react/express_backend/securePostData.js
2022-04-03 20:10:29 +02:00

24 lines
420 B
JavaScript

function secure(text){
text = text.replace(/'/g, "\\u0027");
return text;
}
function decode(text){
text = text.replace(/\\u0027/g, "'");
return text;
}
function secureId(id){
id = id.replace(/'/g, "");
// Regex test if id is a number
let regexPattern = /^[0-9]*$/;
if(!regexPattern.test(id)){
return "";
}
return id;
}
module.exports = {
secure, decode, secureId
}