mirror of
https://github.com/gabrielkheisa/meme-generator-nodejs
synced 2024-11-25 04:43:19 +07:00
9 lines
347 B
JavaScript
9 lines
347 B
JavaScript
|
const sanitizeInput = (text) => {
|
||
|
const allowedCharacters = /^[A-Za-z0-9\s,]$/;
|
||
|
const sanitizedText = text.replace(/[^A-Za-z0-9\s,]/g, '');
|
||
|
return sanitizedText;
|
||
|
};
|
||
|
|
||
|
const input = "<script>alert('Hello, world 123!');</script>";
|
||
|
const sanitizedOutput = sanitizeInput(input);
|
||
|
console.log(sanitizedOutput); // Output: scriptalert(Hello, world!)
|