Skip to content

Commit

Permalink
rollback some of the string slice fixes
Browse files Browse the repository at this point in the history
the Math.max() notation seems a bit long and harder to read
  • Loading branch information
NovemLinguae committed Apr 25, 2024
1 parent b46774b commit ead1538
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
8 changes: 4 additions & 4 deletions src/modules/submissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1044,7 +1044,7 @@

// <ref> 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 <ref> tags are before the references list. You may not see all references.' );
}
}
Expand Down Expand Up @@ -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 ) {
Expand All @@ -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 += '...';
}
Expand Down

0 comments on commit ead1538

Please sign in to comment.