2023-05-06 21:54:49 +01:00
|
|
|
//const log = require('../utils/log.utils');
|
2023-02-09 20:34:53 +00:00
|
|
|
|
2023-07-24 01:04:55 +01:00
|
|
|
function removeNonAlphanumeric(inputString: string) {
|
2023-05-06 21:54:49 +01:00
|
|
|
return inputString.replace(/[^a-zA-Z0-9]/g, '');
|
|
|
|
}
|
2023-02-09 20:34:53 +00:00
|
|
|
|
2023-07-24 01:04:55 +01:00
|
|
|
function removeNonAlpha(inputString: string) {
|
2023-05-06 21:54:49 +01:00
|
|
|
return inputString.replace(/[^a-zA-Z]/g, '');
|
2023-02-09 20:34:53 +00:00
|
|
|
}
|
|
|
|
|
2023-07-24 01:04:55 +01:00
|
|
|
function removeNonNumeric(inputString: string) {
|
2023-05-24 20:42:32 +01:00
|
|
|
return inputString.replace(/[^0-9]/g, '');
|
|
|
|
}
|
|
|
|
|
2023-05-06 21:54:49 +01:00
|
|
|
const cleanApiEndpointTxt = removeNonAlpha;
|
|
|
|
const cleanApiEndpointNum = removeNonAlphanumeric;
|
|
|
|
|
2023-07-24 01:04:55 +01:00
|
|
|
function cleanNrcc(input: string) { // Remove newlines and then <p> tags from input
|
2023-05-06 21:54:49 +01:00
|
|
|
const cleanInput = input.replace(/[\n\r]/g, '').replace(/<\/?p[^>]*>/g, '');
|
|
|
|
return cleanInput;
|
2023-02-09 20:34:53 +00:00
|
|
|
}
|
|
|
|
|
2023-08-01 22:45:08 +01:00
|
|
|
function getDomainFromEmail(mail: string) { // Needs testing
|
2023-05-06 21:54:49 +01:00
|
|
|
let split = mail.split('@');
|
|
|
|
return split[1];
|
2023-02-09 20:34:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
2023-05-06 21:54:49 +01:00
|
|
|
cleanApiEndpointTxt,
|
|
|
|
cleanApiEndpointNum,
|
|
|
|
removeNonAlpha,
|
|
|
|
removeNonAlphanumeric,
|
2023-05-24 20:42:32 +01:00
|
|
|
removeNonNumeric,
|
2023-05-06 21:54:49 +01:00
|
|
|
cleanNrcc,
|
|
|
|
getDomainFromEmail,
|
2023-07-25 01:00:36 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
export {
|
|
|
|
cleanApiEndpointTxt,
|
|
|
|
cleanApiEndpointNum,
|
|
|
|
removeNonAlpha,
|
|
|
|
removeNonAlphanumeric,
|
|
|
|
removeNonNumeric,
|
|
|
|
cleanNrcc,
|
|
|
|
getDomainFromEmail,
|
|
|
|
}
|