fix: % character not properly escaped, closes #60

This commit is contained in:
Fabio Di Stasio 2021-04-28 12:10:43 +02:00
parent fd4f032a6f
commit ecfb732c26
1 changed files with 1 additions and 1 deletions

View File

@ -12,7 +12,7 @@ const regex = new RegExp(pattern);
function sqlEscaper (string) {
return string.replace(regex, char => {
const m = ['\\0', '\\x08', '\\x09', '\\x1a', '\\n', '\\r', '\'', '\"', '\\', '\\\\', '%'];
const r = ['\\\\0', '\\\\b', '\\\\t', '\\\\z', '\\\\n', '\\\\r', '\\\'', '\\\"', '\\\\', '\\\\\\\\', '\\%'];
const r = ['\\\\0', '\\\\b', '\\\\t', '\\\\z', '\\\\n', '\\\\r', '\\\'', '\\\"', '\\\\', '\\\\\\\\', '\%'];
return r[m.indexOf(char)] || char;
});
}