Skip to content

Commit

Permalink
fix detection of {{OKA}} banner (wikimedia-gadgets#371)
Browse files Browse the repository at this point in the history
should be placed in the banner shell
  • Loading branch information
NovemLinguae authored Aug 23, 2024
1 parent df54c41 commit 0d3dbf7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/modules/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1653,7 +1653,7 @@
addTalkPageBanners: function ( wikicode, newAssessment, revId, isBiography, newWikiProjects, lifeStatus, subjectName ) {
// build an array of all banners already on page
var bannerTemplates = 'wikiproject (?!banner)|football|oka';
var bannerTemplateRegEx = new RegExp( '{{(?:' + bannerTemplates + ')[^}]+}}', 'gi' );
var bannerTemplateRegEx = new RegExp( '{{(?:' + bannerTemplates + ')[^}]*}}', 'gi' );
var banners = wikicode.match( bannerTemplateRegEx ) || [];

// delete all banners already on page
Expand Down
19 changes: 19 additions & 0 deletions tests/test-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,25 @@ I have a question. Can you help answer it? –[[User:Novem Linguae|<span style="
}}`
);
} );

it( 'has {{OKA}} banner and puts it in the banner shell', function () {
var wikicode =
`{{translated page|pl|Katowice Załęże|version=|small=no|insertversion=|section=}}{{OKA}}`;
var newAssessment = '';
var revId = 592681;
var isBiography = false;
var newWikiProjects = [];
var lifeStatus = 'unknown';
var subjectName = '';
var output = AFCH.addTalkPageBanners( wikicode, newAssessment, revId, isBiography, newWikiProjects, lifeStatus, subjectName );
expect( output ).toBe(
`{{WikiProject banner shell|
{{OKA}}
{{subst:WPAFC/article|oldid=592681}}
}}
{{translated page|pl|Katowice Załęże|version=|small=no|insertversion=|section=}}`
);
} );
} );

describe( 'AFCH.removeDuplicateBanners', function () {
Expand Down

0 comments on commit 0d3dbf7

Please sign in to comment.