diff --git a/package.json b/package.json index 94d161e..582cbcd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "interlanguage-checker", - "version": "1.13.3", + "version": "1.13.4", "description": "Check the consistency of MediaWiki interlanguage links in a simple overview.", "author": "Felix W. Dekker", "browser": "dist/bundle.js", diff --git a/src/main/js/MediaWiki.ts b/src/main/js/MediaWiki.ts index 312fa7f..79e06d1 100644 --- a/src/main/js/MediaWiki.ts +++ b/src/main/js/MediaWiki.ts @@ -324,7 +324,7 @@ export class MediaWiki { /** * The namespaces on this wiki. */ - namespaces!: Map; + namespaces!: Map; /** @@ -355,7 +355,13 @@ export class MediaWiki { this.general = query.general; this.interwikiMap = new Map(query.interwikimap.map((it: { prefix: string, url: string }) => [it.prefix, it.url])); - this.namespaces = query.namespaces; + this.namespaces = + new Map( + Object.keys(query.namespaces).map(id => { + const props = query.namespaces[id]; + return [+id, {canonical: props.canonical, "*": props["*"]}]; + }) + ); return this; } @@ -437,9 +443,7 @@ export class MediaWiki { if (titleParts.length < 2) return new InterlangLink(normalLang, link.title); titleParts[0] = [...this.namespaces.values()].reduce( - (titlePart: string, namespace: { id: string, canonical: string, "*": string }) => { - return titlePart === namespace["canonical"] ? namespace["*"] : titlePart; - }, + (titlePart, namespace) => titlePart === namespace["canonical"] ? namespace["*"] : titlePart, titleParts[0] ); const normalTitle = titleParts.join(":");