Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
NovemLinguae committed Jul 21, 2023
1 parent 3489841 commit 2b6f3dc
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions modules/twinklearv.js
Original file line number Diff line number Diff line change
Expand Up @@ -509,11 +509,9 @@ Twinkle.arv.callback.evaluate = function(e) {
}
}).join('; ');


if (form.page.value !== '') {
// Allow links to redirects, files, and categories
reason = 'On {{No redirect|:' + form.page.value + '}}';

if (form.badid.value !== '') {
reason += ' ({{diff|' + form.page.value + '|' + form.badid.value + '|' + form.goodid.value + '|diff}})';
}
Expand All @@ -523,17 +521,21 @@ Twinkle.arv.callback.evaluate = function(e) {
if (types) {
reason += ' ' + types;
}

if (comment !== '') {
var reasonNeedsPunctuation = /([.?!;:]|^)$/.test(reason);
reason += reasonNeedsPunctuation ? '' : '.';
var reasonEndsInPunctuationOrBlank = /([.?!;:]|^)$/.test(reason);
reason += reasonEndsInPunctuationOrBlank ? '' : '.';
var reasonIsBlank = reason === '';
reason += reasonIsBlank ? '' : ' ';
reason += comment;
}

reason = reason.trim();
if (!/[.?!;]$/.test(reason)) {
var reasonEndsInPunctuation = /[.?!;]$/.test(reason);
if (!reasonEndsInPunctuation) {
reason += '.';
}

reason += ' ~~~~';
reason = reason.replace(/\r?\n/g, '\n*:'); // indent newlines

Expand Down

0 comments on commit 2b6f3dc

Please sign in to comment.