diff --git a/src/ui/root/DeputyContributionSurveySection.tsx b/src/ui/root/DeputyContributionSurveySection.tsx index a26c17fe..234d024e 100644 --- a/src/ui/root/DeputyContributionSurveySection.tsx +++ b/src/ui/root/DeputyContributionSurveySection.tsx @@ -25,6 +25,7 @@ import DeputyExtraneousElement from './DeputyExtraneousElement'; import classMix from '../../util/classMix'; import dangerModeConfirm from '../../util/dangerModeConfirm'; import normalizeWikiHeading, { WikiHeading } from '../../wiki/util/normalizeWikiHeading'; +import parseDiffUrl from '../../wiki/util/parseDiffUrl'; /** * The contribution survey section UI element. This includes a list of revisions @@ -356,8 +357,15 @@ export default class DeputyContributionSurveySection implements DeputyUIElement const anchor: HTMLElement = li.querySelector( 'a:first-of-type' ); // Avoid enlisting if the anchor can't be found (invalid row). if ( anchor ) { - rowElements[ new mw.Title( anchor.innerText ).getPrefixedText() ] = - li as HTMLLIElement; + const anchorLinkTarget = parseDiffUrl( + new URL( anchor.getAttribute( 'href' ), window.location.href ) + ).title; + if ( !anchorLinkTarget ) { + warn( 'Could not parse target of anchor', anchor ); + } else { + rowElements[ new mw.Title( anchorLinkTarget ).getPrefixedText() ] = + li as HTMLLIElement; + } } } } @@ -384,6 +392,7 @@ export default class DeputyContributionSurveySection implements DeputyUIElement ); } else { // Element somehow not in list. Just keep line as-is. + warn( `Could not find row element for "${csr.title.getPrefixedText()}"` ); rowElement = line; } } catch ( e ) { diff --git a/src/wiki/util/parseDiffUrl.ts b/src/wiki/util/parseDiffUrl.ts index c907c83e..0b5eeff2 100644 --- a/src/wiki/util/parseDiffUrl.ts +++ b/src/wiki/util/parseDiffUrl.ts @@ -11,6 +11,8 @@ interface DiffInfo { * or `oldid` from a URL. This is useful for converting diff URLs into actual * diff information, and especially useful for {{copied}} templates. * + * If diff parameters were not found (no `diff` or `oldid`), they will be `null`. + * * @param url The URL to parse * @return Parsed info: `diff` or `oldid` revision IDs, and/or the page title. */ @@ -66,7 +68,7 @@ export default function parseDiffUrl( url: URL | string ): DiffInfo { const articlePathRegex = new RegExp( mw.util.getUrl( '(.*)' ) ) .exec( url.pathname ); if ( articlePathRegex != null ) { - title = articlePathRegex[ 1 ]; + title = decodeURIComponent( articlePathRegex[ 1 ] ); break tryConvert; } }