Skip to content

Commit

Permalink
fix #229 *#: in front of {{Unblock reviewed}} causes display glitch
Browse files Browse the repository at this point in the history
  • Loading branch information
NovemLinguae committed Nov 7, 2024
1 parent 50f4e50 commit 2b30dbd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
3 changes: 0 additions & 3 deletions UnblockReview/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ TODO:
const acceptDeclineReason = reasonArea.value;
wikitext = unblockReview.processAcceptOrDecline( wikitext, appealReason, acceptDeclineReason, DEFAULT_DECLINE_REASON, acceptOrDecline );

// get rid of any colons in front of {{unblock X}} templates. causes a bug.
// wikitext = wikitext.replace( /^:{1,}\s*(\{\{\s*unblock)/mi, '$1' );

// build edit summary
const acceptingOrDeclining = ( acceptOrDecline === 'accept' ? 'Accepting' : 'Declining' );
const summary = acceptingOrDeclining + ' unblock request' + ADVERT;
Expand Down
3 changes: 3 additions & 0 deletions UnblockReview/modules/UnblockReview.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export class UnblockReview {
'{{unblock reviewed|' + acceptOrDecline + '=' + acceptDeclineReason + '|1=' + appealReason
);

// get rid of any [#*:] in front of {{unblock X}} templates. indentation messes up the background color and border of the unblock template.
wikitext = wikitext.replace( /^[#*:\s]{1,}(\{\{\s*unblock)/mi, '$1' );

return wikitext;
}

Expand Down
18 changes: 18 additions & 0 deletions UnblockReview/tests/UnblockReview.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,22 @@ describe( 'processAcceptOrDecline( wikitext, appealReason, acceptDeclineReason,
const expected = `Test {{unblock reviewed|decline=Insufficient. ~~~~|1=Your reason here [[User:Filipe46|Filipe46]] ([[User talk:Filipe46#top|talk]]) 21:54, 25 November 2021 (UTC)}} Test`;
expect( unblockReview.processAcceptOrDecline( wikitext, appealReason, acceptDeclineReason, DEFAULT_DECLINE_REASON, acceptOrDecline ) ).toBe( expected );
} );

test( 'Colon in front of {{Unblock}}', () => {
const wikitext = `:{{unblock|reason=Your reason here [[User:Filipe46|Filipe46]] ([[User talk:Filipe46#top|talk]]) 21:54, 25 November 2021 (UTC)}}`;
const appealReason = `Your reason here `;
const acceptDeclineReason = `Insufficient. ~~~~`;
const acceptOrDecline = `decline`;
const expected = `{{unblock reviewed|decline=Insufficient. ~~~~|1=Your reason here [[User:Filipe46|Filipe46]] ([[User talk:Filipe46#top|talk]]) 21:54, 25 November 2021 (UTC)}}`;
expect( unblockReview.processAcceptOrDecline( wikitext, appealReason, acceptDeclineReason, DEFAULT_DECLINE_REASON, acceptOrDecline ) ).toBe( expected );
} );

test( 'Bulleted list and colon in front of {{Unblock}}', () => {
const wikitext = `*:{{unblock|reason=Your reason here [[User:Filipe46|Filipe46]] ([[User talk:Filipe46#top|talk]]) 21:54, 25 November 2021 (UTC)}}`;
const appealReason = `Your reason here `;
const acceptDeclineReason = `Insufficient. ~~~~`;
const acceptOrDecline = `decline`;
const expected = `{{unblock reviewed|decline=Insufficient. ~~~~|1=Your reason here [[User:Filipe46|Filipe46]] ([[User talk:Filipe46#top|talk]]) 21:54, 25 November 2021 (UTC)}}`;
expect( unblockReview.processAcceptOrDecline( wikitext, appealReason, acceptDeclineReason, DEFAULT_DECLINE_REASON, acceptOrDecline ) ).toBe( expected );
} );
} );

0 comments on commit 2b30dbd

Please sign in to comment.