mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Enable no-regex-spaces lint
I noticed the old code was replacing two spaces with one space, over and over. Instead, I changed it to remove all consecutive strings of spaces just once, using the "+" quantifier. This should behave the same but is nicer to read and faster.
This commit is contained in:
@@ -12,9 +12,7 @@ const writeFileAtomicSync = require('write-file-atomic').sync;
|
||||
*/
|
||||
function safeStr(x) {
|
||||
x = String(x);
|
||||
for (let i = 0; i < 16; i++) {
|
||||
x = x.replace(/ /g, ' ');
|
||||
}
|
||||
x = x.replace(/ +/g, ' ');
|
||||
x = x.trim();
|
||||
x = x.replace(/^[\s,.]+|[\s,.]+$/g, '');
|
||||
return x;
|
||||
|
Reference in New Issue
Block a user