From 2b6f3dce91ed85ec9cd3b357c4986e5ff94821e7 Mon Sep 17 00:00:00 2001 From: NovemLinguae Date: Fri, 21 Jul 2023 01:14:04 -0700 Subject: [PATCH] refactor --- modules/twinklearv.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/twinklearv.js b/modules/twinklearv.js index 7753bd1a1..065819c03 100644 --- a/modules/twinklearv.js +++ b/modules/twinklearv.js @@ -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}})'; } @@ -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