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-08-26 00:38:26 +01:00
|
|
|
return inputString.replace(/[^a-zA-Z0-9]/g, "");
|
2023-05-06 21:54:49 +01:00
|
|
|
}
|
2023-02-09 20:34:53 +00:00
|
|
|
|
2023-08-26 00:38:26 +01:00
|
|
|
function removeNonAlpha(inputString: string) {
|
|
|
|
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-08-26 00:38:26 +01:00
|
|
|
return inputString.replace(/[^0-9]/g, "");
|
2023-05-24 20:42:32 +01:00
|
|
|
}
|
|
|
|
|
2023-05-06 21:54:49 +01:00
|
|
|
const cleanApiEndpointTxt = removeNonAlpha;
|
|
|
|
const cleanApiEndpointNum = removeNonAlphanumeric;
|
|
|
|
|
2023-08-26 00:38:26 +01:00
|
|
|
function cleanNrcc(input: string) {
|
|
|
|
// Remove newlines and then <p> tags from input
|
|
|
|
const cleanInput = input.replace(/[\n\r]/g, "").replace(/<\/?p[^>]*>/g, "");
|
2023-05-06 21:54:49 +01:00
|
|
|
return cleanInput;
|
2023-02-09 20:34:53 +00:00
|
|
|
}
|
|
|
|
|
2023-08-26 00:38:26 +01:00
|
|
|
function getDomainFromEmail(mail: string) {
|
|
|
|
// Needs testing
|
|
|
|
let split = mail.split("@");
|
2023-05-06 21:54:49 +01:00
|
|
|
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,
|
2023-08-26 00:38:26 +01:00
|
|
|
};
|