mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-06 05:43:47 +08:00
escaping characters used by regex
This commit is contained in:
parent
79afe812f5
commit
254a0414a5
1 changed files with 2 additions and 1 deletions
|
@ -2097,7 +2097,8 @@ function updateSuggestedCommands() {
|
|||
let foundcount = 0;
|
||||
$.each(inputVal, (index2, obj2) => {
|
||||
if (obj2 == "") return;
|
||||
let re = new RegExp("\\b" + obj2, "g");
|
||||
let escaped = obj2.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
||||
let re = new RegExp("\\b" + escaped, "g");
|
||||
let res = obj.display.toLowerCase().match(re);
|
||||
if (res != null && res.length > 0) {
|
||||
foundcount++;
|
||||
|
|
Loading…
Reference in a new issue