43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
const clean = require('string-sanitizer-fix');
|
|
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, '');
|
|
}
|
|
|
|
function cleanApiEndpointTxt(input) {
|
|
var output = clean.sanitize.keepSpace(input)
|
|
if (output != input){
|
|
log.out(`sanitizerUtils.cleanApiEndpoint: WARN: Sanitizing changed string. Input = ${input}`, "warn");
|
|
}
|
|
return output
|
|
}
|
|
|
|
function cleanApiEndpointNum(input) {
|
|
var output = clean.sanitize.keepNumber(input)
|
|
if (output != input){
|
|
log.out(`sanitizerUtils.cleanApiEndpointNum: WARN: Sanitizing changed string. Input = ${input}`, "warn");
|
|
}
|
|
return output
|
|
}
|
|
|
|
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
|
|
split = mail.split("@")
|
|
return split[1]
|
|
}
|
|
|
|
module.exports = {
|
|
cleanApiEndpointTxt,
|
|
cleanApiEndpointNum,
|
|
cleanNrcc,
|
|
getDomainFromEmail,
|
|
} |