🚚 Refactor form elemts

This commit is contained in:
Alicia Sykes
2021-10-02 22:35:47 +01:00
parent 11d9ea535b
commit 848b661c76
3 changed files with 22 additions and 3 deletions

View File

@@ -11,3 +11,17 @@ export const asciiHash = (input) => {
const shortened = asciiSum.slice(0, 30) + asciiSum.slice(asciiSum.length - 30);
return window.btoa(shortened);
};
/* Encode potentially malicious characters from string */
export const sanitize = (string) => {
const map = {
'&': '&',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#x27;',
'/': '&#x2F;',
};
const reg = /[&<>"'/]/ig;
return string.replace(reg, (match) => (map[match]));
};