only use new RegExp(...) to define regex (not slashes)

This commit is contained in:
John R. Supplee 2021-01-29 13:15:53 +02:00
parent 6ba4da9711
commit 3435192640
2 changed files with 19 additions and 6 deletions

View file

@ -1263,12 +1263,16 @@ function boardRemover(userId, doc) {
}
Boards.uniqueTitle = title => {
const m = title.match(/^(?<title>.*?)\s*(\[(?<num>\d+)]\s*$|\s*$)/);
const m = title.match(
new RegExp('^(?<title>.*?)\\s*(\\[(?<num>\\d+)]\\s*$|\\s*$)'),
);
const base = escapeForRegex(m.groups.title);
let num = 0;
Boards.find({ title: new RegExp(`^${base}\\s*\\[\\d+]\\s*$`) }).forEach(
board => {
const m = board.title.match(/^(?<title>.*?)\s*\[(?<num>\d+)]\s*$/);
const m = board.title.match(
new RegExp('^(?<title>.*?)\\s*\\[(?<num>\\d+)]\\s*$'),
);
if (m) {
const n = parseInt(m.groups.num, 10);
num = num < n ? n : num;