parent
c9dec6371d
commit
eacb38928e
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "interlanguage-checker",
|
||||
"version": "1.11.7",
|
||||
"version": "1.12.0",
|
||||
"description": "Check the consistency of MediaWiki interlanguage links in a simple overview.",
|
||||
"author": "Felix W. Dekker",
|
||||
"browser": "dist/bundle.js",
|
||||
|
|
|
@ -356,6 +356,8 @@ export class InterlangTable {
|
|||
return this._createIcon("chain-broken", "Misses one or more links 😕", ["error"]);
|
||||
case "redirected":
|
||||
return this._createIcon("mail-forward", "Links to a redirect 😕", ["warning"]);
|
||||
case "wrongly-cased":
|
||||
return this._createIcon("text-height", "Links with incorrect capitalisation 😕", ["warning"]);
|
||||
default:
|
||||
throw new Error(`Invalid page state '${state}'`);
|
||||
}
|
||||
|
@ -375,6 +377,8 @@ export class InterlangTable {
|
|||
return `<span></span>`;
|
||||
case "redirected":
|
||||
return this._createIcon("mail-forward", "Links to a redirect 😕", ["warning"]);
|
||||
case "wrongly-cased":
|
||||
return this._createIcon("text-height", "Links with incorrect capitalisation 😕", ["warning"]);
|
||||
default:
|
||||
throw new Error(`Invalid link state '${linkState}'`);
|
||||
}
|
||||
|
|
|
@ -33,6 +33,18 @@ export class InterlangLink {
|
|||
return other instanceof InterlangLink && this.lang === other.lang && this.title === other.title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if and only if the given object equals this `InterlangLink`, ignoring the case of the titles.
|
||||
*
|
||||
* @param other {*} the object to compare to this `InterlangLink`
|
||||
* @returns {boolean} `true` if and only if the given object equals this `InterlangLink`, ignoring the case of the
|
||||
* titles
|
||||
*/
|
||||
equalsIgnoringCase(other) {
|
||||
return other instanceof InterlangLink && this.lang === other.lang
|
||||
&& this.title.toLowerCase() === other.title.toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts this `InterlangLink` to a string.
|
||||
*
|
||||
|
@ -232,6 +244,9 @@ export class InterlangNetwork {
|
|||
if (source.langLinks.some(it => it.equals(destination.link)))
|
||||
return isSelfLangLink ? "self-linked" : "linked";
|
||||
|
||||
if (source.langLinks.some(it => it.equalsIgnoringCase(destination.link)))
|
||||
return isSelfLangLink ? "self-linked" : "wrongly-cased";
|
||||
|
||||
if (source.langLinks.some(link => this.redirects.some(it => it.equals(new Redirect(link, destination.link)))))
|
||||
return isSelfLangLink ? "self-linked" : "redirected";
|
||||
|
||||
|
@ -267,6 +282,8 @@ export class InterlangNetwork {
|
|||
selfStates.push("unlinked");
|
||||
if (pageStates.some(({verdict}) => verdict === "redirected"))
|
||||
selfStates.push("redirected");
|
||||
if (pageStates.some(({verdict}) => verdict === "wrongly-cased"))
|
||||
selfStates.push("wrongly-cased");
|
||||
|
||||
if (selfStates.length === 0)
|
||||
selfStates.push("perfect");
|
||||
|
@ -285,7 +302,7 @@ export class InterlangNetwork {
|
|||
const verdict = this.getPageVerdict(page).self;
|
||||
if (verdict.some(it => ["not-found", "unlinked"].includes(it)))
|
||||
return mergeStates(states, state, "broken");
|
||||
if (verdict.some(it => ["wrongly-ordered", "doubly-linked", "self-linked", "redirected"].includes(it)))
|
||||
if (verdict.some(it => ["wrongly-ordered", "doubly-linked", "self-linked", "redirected", "wrongly-cased"].includes(it)))
|
||||
return mergeStates(states, state, "flawed");
|
||||
return mergeStates(states, state, "perfect");
|
||||
}, "perfect");
|
||||
|
|
Loading…
Reference in New Issue