diff --git a/.eslintrc.json b/.eslintrc.json index 7c2a6737..a6edcde3 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -30,6 +30,7 @@ "no-unused-vars": "warn", "no-use-before-define": "warn", "security/detect-non-literal-regexp": "off", - "security/detect-unsafe-regex": "off" + "security/detect-unsafe-regex": "off", + "unicorn/prefer-string-slice": "off" } } diff --git a/src/modules/submissions.js b/src/modules/submissions.js index 4c05450d..8057b525 100644 --- a/src/modules/submissions.js +++ b/src/modules/submissions.js @@ -712,7 +712,7 @@ match = categoryRegex.exec( text ); } - text = text.slice( 0, Math.max( 0, catIndex ) ) + newCategoryCode + text.slice( Math.max( 0, catIndex ) ); + text = text.substring( 0, catIndex ) + newCategoryCode + text.substring( catIndex ); } this.text = text; @@ -1044,7 +1044,7 @@ // after {{reflist}} if ( hasReflist ) { - if ( refBeginRe.test( text.slice( Math.max( 0, reflistRe.lastIndex ) ) ) ) { + if ( refBeginRe.test( text.substring( reflistRe.lastIndex ) ) ) { addWarning( 'Not all of the tags are before the references list. You may not see all references.' ); } } @@ -2575,7 +2575,7 @@ if ( declineReason === 'reason' ) { // If this is a custom decline, use the text in the edit summary - editSummary += data.declineTextarea.slice( 0, Math.max( 0, lengthLimit ) ); + editSummary += data.declineTextarea.substring( 0, lengthLimit ); // If we had to trunucate, indicate that if ( data.declineTextarea.length > lengthLimit ) { @@ -2588,7 +2588,7 @@ if ( declineReason2 ) { editSummary += ' and '; if ( declineReason2 === 'reason' ) { - editSummary += data.declineTextarea.slice( 0, Math.max( 0, lengthLimit ) ); + editSummary += data.declineTextarea.substring( 0, lengthLimit ); if ( data.declineTextarea.length > lengthLimit ) { editSummary += '...'; }