@@ -117,24 +117,18 @@ export default class CopyrightProblemsListing {
117
117
// Get the page title based on the anchor, verified by the link.
118
118
// This ensures we're always using the prefixedDb version of the title (as
119
119
// provided by the anchor) for stability.
120
- let title : mw . Title ;
121
120
const prefixedDb = anchor . getAttribute ( 'id' ) ;
122
121
const href = el . getAttribute ( 'href' ) ;
123
- if ( prefixedDb == null ) {
124
- // Not an anchor.
125
- return false ;
126
- } else if ( href === mw . util . getUrl ( prefixedDb ) ) {
127
- // The page exists and links to the correct page.
128
- title = new mw . Title ( prefixedDb ) ;
129
- } else if ( new RegExp (
130
- `[?&]title=${ mw . util . escapeRegExp ( prefixedDb ) } (?:&|$)`
131
- ) . test ( prefixedDb ) ) {
132
- // The page does not exist but it links to the correct page.
133
- title = new mw . Title ( prefixedDb ) ;
134
- } else {
135
- // The page does not link to the correct page.
136
- return false ;
137
- }
122
+ const title = anchorToTitle ( el as HTMLAnchorElement ) ;
123
+
124
+ if ( title === false ) {
125
+ // Not a valid link.
126
+ return false ;
127
+ } else if ( title . getPrefixedText ( ) !== new mw . Title ( prefixedDb ) . getPrefixedText ( ) ) {
128
+ // Anchor and link mismatch. Someone tampered with the template?
129
+ // In this case, rely on the link instead, as the anchor is merely invisible.
130
+ console . warn ( `Anchor and link mismatch for "${ title . getPrefixedText ( ) } ".` , title , prefixedDb ) ;
131
+ }
138
132
139
133
// Checks for the <span class="plainlinks"> element.
140
134
// This ensures that the listing came from {{article-cv}} and isn't just a
@@ -371,9 +365,10 @@ export default class CopyrightProblemsListing {
371
365
* use `addComment` instead.
372
366
*
373
367
* @param message
368
+ * @param summary
374
369
* @param indent
375
370
*/
376
- async respond ( message : string , indent = false ) : Promise < void > {
371
+ async respond ( message : string , summary ?: string , indent = false ) : Promise < void > {
377
372
const newWikitext = await this . addComment ( message , indent ) ;
378
373
379
374
await MwApi . action . postWithEditToken ( {
@@ -385,7 +380,7 @@ export default class CopyrightProblemsListing {
385
380
text : newWikitext ,
386
381
// TODO: l10n
387
382
summary : decorateEditSummary (
388
- `Responding to [[${
383
+ summary ?? `Responding to [[${
389
384
this . listingPage . title . getPrefixedText ( )
390
385
} #${
391
386
this . title . getPrefixedText ( )
0 commit comments