From c36bf8e3577da31cf6d575879c7e92d3e9c7e4f1 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Fri, 23 Feb 2024 06:05:19 -0300 Subject: Big cleanup - delete all SQLite Node-API code: we'll use the C++ one instead; - implement hero.mjs, with tests! - use ESM all over. --- src/escape.mjs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/escape.mjs (limited to 'src/escape.mjs') diff --git a/src/escape.mjs b/src/escape.mjs new file mode 100644 index 0000000..78e08f8 --- /dev/null +++ b/src/escape.mjs @@ -0,0 +1,14 @@ +const FROM = /[&<>'"]/g; + +const ESCAPES = { + '&': '&', + '<': '<', + '>': '>', + "'": ''', + '"': '"' +}; + +const mappingFn = c => ESCAPES[c]; + +export const escape = s => + String.prototype.replace.call(s, FROM, mappingFn); -- cgit v1.2.3