Skip to content

Commit 0d0fb57

Browse files
committed
Replace regular expressions with replaceAll
1 parent 68ca3d7 commit 0d0fb57

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/database.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const where = (conditions, firstArgIndex = 1) => {
2323
}
2424
if (value.includes('*') || value.includes('?')) {
2525
operator = 'LIKE';
26-
value = value.replace(/\*/g, '%').replace(/\?/g, '_');
26+
value = value.replace('*', '%').replace('?', '_');
2727
}
2828
}
2929
clause.push(`${key} ${operator} $${i++}`);

lib/logger.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Logger {
1818
const date = new Date().toISOString().substring(0, 10);
1919
const filePath = path.join(logPath, `${date}-W${threadId}.log`);
2020
this.stream = fs.createWriteStream(filePath, { flags: 'a' });
21-
this.regexp = new RegExp(path.dirname(this.path), 'g');
21+
this.home = path.dirname(this.path);
2222
}
2323

2424
close() {
@@ -31,7 +31,7 @@ class Logger {
3131
const color = COLORS[level];
3232
const line = date + '\t' + s;
3333
console.log(color + line + '\x1b[0m');
34-
const out = line.replace(/[\n\r]\s*/g, '; ') + '\n';
34+
const out = line.replaceAll('\n', '; ') + '\n';
3535
this.stream.write(out);
3636
}
3737

@@ -51,8 +51,8 @@ class Logger {
5151
}
5252

5353
error(...args) {
54-
const msg = util.format(...args).replace(/[\n\r]{2,}/g, '\n');
55-
this.write('error', msg.replace(this.regexp, ''));
54+
const msg = util.format(...args);
55+
this.write('error', msg.replaceAll(this.home, ''));
5656
}
5757

5858
system(...args) {

0 commit comments

Comments
 (0)