Skip to content

Commit

Permalink
chore: cleanup escapes in utils
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianMurphy committed Jun 19, 2024
1 parent de01fa3 commit 26a3993
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ var up = up || {};
* @param str {String} String to be cleaned
*/
up.escapeSpecialChars = function (string_) {
var specials = new RegExp('[.*+?|()\\[\\]{}\\\\]', 'g'); // .*+?|()[]{}\
return string_.replaceAll(specials, '\\$&');
var specials = new RegExp(String.raw`[.*+?|()\[\]{}\\]`, 'g'); // .*+?|()[]{}\
return string_.replaceAll(specials, String.raw`\$&`);
};

/**
Expand Down Expand Up @@ -146,7 +146,7 @@ var up = up || {};
var s = message;

for (var index = 0; index < arguments_.length; index++) {
var reg = new RegExp('\\{' + index + '\\}', 'gm');
var reg = new RegExp(String.raw`\{` + index + String.raw`\}`, 'gm');
s = s.replace(reg, arguments_[index]);
}
return s;
Expand Down

0 comments on commit 26a3993

Please sign in to comment.