refactor: replace deprecated String.prototype.substr() (#10432)

.substr() is deprecated so we replace it with .slice() which works similarily but isn't deprecated

Signed-off-by: Tobias Speicher <rootcommander@gmail.com>
This commit is contained in:
CommanderRoot
2022-03-31 19:49:56 +02:00
committed by GitHub
parent 0d744d30f2
commit 200f0b2e4f
19 changed files with 26 additions and 26 deletions

View File

@@ -335,7 +335,7 @@
// see https://github.com/NodeBB/NodeBB/issues/4378
tag = tag.replace(/\u202E/gi, '');
tag = tag.replace(/[,/#!$^*;:{}=_`<>'"~()?|]/g, '');
tag = tag.substr(0, maxLength || 15).trim();
tag = tag.slice(0, maxLength || 15).trim();
const matches = tag.match(/^[.-]*(.+?)[.-]*$/);
if (matches && matches.length > 1) {
tag = matches[1];
@@ -652,7 +652,7 @@
);
if (key) {
if (key.substr(-2, 2) === '[]') {
if (key.slice(-2) === '[]') {
key = key.slice(0, -2);
}
if (!hash[key]) {