Skip to content

Commit f8ab4e6

Browse files
committed
UnblockReview: fix an {{unblock-spamun}} bug
fixes #258
1 parent 46e86b0 commit f8ab4e6

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

UnblockReview/modules/UnblockReview.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,15 @@ export class UnblockReview {
119119
continue;
120120
}
121121

122+
// Don't match already reviewed templates. These are marked with the word "reviewed". Example: {{unblock-spamun reviewed|
123+
if ( initialText.match( /\s+reviewed\s*\|/ ) ) {
124+
continue;
125+
}
126+
122127
return initialText;
123128
}
124129

125-
throw new Error( 'Searching backwards failed!' );
130+
throw new Error( 'Failed to find left half of unblock template in the wikicode' );
126131
}
127132

128133
/**

UnblockReview/tests/UnblockReview.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,15 @@ describe( 'getLeftHalfOfUnblockTemplate( wikitext, appealReason )', () => {
123123
const expected = `{{unblock|reason=`;
124124
expect( unblockReview.getLeftHalfOfUnblockTemplate( wikitext, appealReason ) ).toBe( expected );
125125
} );
126+
127+
test( `Don't match {{unblock-spamun reviewed}}`, () => {
128+
const wikitext =
129+
`{{unblock-spamun reviewed|Kadenwithacat|Test 1}}
130+
{{unblock-spamun|Kadenwithacat|Test 2}}`;
131+
const appealReason = `Kadenwithacat`;
132+
const expected = `{{unblock-spamun|`;
133+
expect( unblockReview.getLeftHalfOfUnblockTemplate( wikitext, appealReason ) ).toBe( expected );
134+
} );
126135
} );
127136

128137
describe( 'processAcceptOrDecline( wikitext, paramsAndReason, acceptDeclineReason, DEFAULT_DECLINE_REASON, acceptOrDecline )', () => {

0 commit comments

Comments
 (0)