backend/src/utils/sanitizer.utils.js

31 lines
864 B
JavaScript
Raw Normal View History

//const log = require('../utils/log.utils');
function removeNonAlphanumeric(inputString) { // Should be able to replace sanitizer module
return inputString.replace(/[^a-zA-Z0-9]/g, '');
}
function removeNonAlpha(inputString) { // Should be able to replace sanitizer module
return inputString.replace(/[^a-zA-Z]/g, '');
}
const cleanApiEndpointTxt = removeNonAlpha;
const cleanApiEndpointNum = removeNonAlphanumeric;
function cleanNrcc(input) { // Remove newlines and then <p> tags from input
const cleanInput = input.replace(/[\n\r]/g, '').replace(/<\/?p[^>]*>/g, '');
return cleanInput;
}
async function getDomainFromEmail(mail) { // Needs testing
let split = mail.split('@');
return split[1];
}
module.exports = {
cleanApiEndpointTxt,
cleanApiEndpointNum,
removeNonAlpha,
removeNonAlphanumeric,
cleanNrcc,
getDomainFromEmail,
};