@@ -117,24 +117,18 @@ export default class CopyrightProblemsListing {
117117 // Get the page title based on the anchor, verified by the link.
118118 // This ensures we're always using the prefixedDb version of the title (as
119119 // provided by the anchor) for stability.
120- let title : mw . Title ;
121120 const prefixedDb = anchor . getAttribute ( 'id' ) ;
122121 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+ }
138132
139133 // Checks for the <span class="plainlinks"> element.
140134 // This ensures that the listing came from {{article-cv}} and isn't just a
@@ -371,9 +365,10 @@ export default class CopyrightProblemsListing {
371365 * use `addComment` instead.
372366 *
373367 * @param message
368+ * @param summary
374369 * @param indent
375370 */
376- async respond ( message : string , indent = false ) : Promise < void > {
371+ async respond ( message : string , summary ?: string , indent = false ) : Promise < void > {
377372 const newWikitext = await this . addComment ( message , indent ) ;
378373
379374 await MwApi . action . postWithEditToken ( {
@@ -385,7 +380,7 @@ export default class CopyrightProblemsListing {
385380 text : newWikitext ,
386381 // TODO: l10n
387382 summary : decorateEditSummary (
388- `Responding to [[${
383+ summary ?? `Responding to [[${
389384 this . listingPage . title . getPrefixedText ( )
390385 } #${
391386 this . title . getPrefixedText ( )
0 commit comments