parent
6a7aaaef7c
commit
e84d87ced6
|
@ -53,8 +53,8 @@
|
||||||
<br />
|
<br />
|
||||||
To use the tool, you should enter the link to the
|
To use the tool, you should enter the link to the
|
||||||
<a href="https://www.mediawiki.org/wiki/API:Main_page">API of the wiki</a> you want to check.
|
<a href="https://www.mediawiki.org/wiki/API:Main_page">API of the wiki</a> you want to check.
|
||||||
For <b>Wikimedia</b> wikis, this is <code><example.org>/w/api.php</code>.
|
For <b>Wikimedia</b> wikis, this is <code>https://<example.org>/w/api.php</code>.
|
||||||
For <b>Fandom</b> wikis, this is <code><wiki>.fandom.com/api.php</code>.<br />
|
For <b>Fandom</b> wikis, this is <code>https://<wiki>.fandom.com/api.php</code>.<br />
|
||||||
<br />
|
<br />
|
||||||
If you need <b>help</b>, have a <b>question</b>, or found a <b>bug</b>, please
|
If you need <b>help</b>, have a <b>question</b>, or found a <b>bug</b>, please
|
||||||
<a href="https://git.fwdekker.com/FWDekker/interlanguage-checker/issues/new">open an issue</a>
|
<a href="https://git.fwdekker.com/FWDekker/interlanguage-checker/issues/new">open an issue</a>
|
||||||
|
|
|
@ -348,7 +348,7 @@ export class MediaWiki {
|
||||||
return fetchJsonp(url)
|
return fetchJsonp(url)
|
||||||
.then(it => it.json())
|
.then(it => it.json())
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
throw new Error("Could not to connect to API. Is the URL correct?")
|
throw new Error("Could not to connect to API. Is the URL correct? See the <b>About</b> section for more information.")
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -489,7 +489,13 @@ export class MediaWikiManager {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|
||||||
const url = this._iwMap.getUrl(lang);
|
const url = this._iwMap.getUrl(lang);
|
||||||
const newMw = await new MediaWiki(url.slice(0, -this.articlePath.length) + this.apiPath).init();
|
let newMw;
|
||||||
|
try {
|
||||||
|
newMw = await new MediaWiki(url.slice(0, -this.articlePath.length) + this.apiPath).init();
|
||||||
|
} catch (error) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.hasMw(newMw.general.lang)) {
|
if (this.hasMw(newMw.general.lang)) {
|
||||||
this.mws[lang] = this.mws[newMw.general.lang];
|
this.mws[lang] = this.mws[newMw.general.lang];
|
||||||
} else {
|
} else {
|
||||||
|
@ -566,6 +572,15 @@ export const discoverNetwork = async function (mwm, title, progressCb) {
|
||||||
|
|
||||||
// Normalize
|
// Normalize
|
||||||
const nextMw = await mwm.getMwOrWait(next.lang);
|
const nextMw = await mwm.getMwOrWait(next.lang);
|
||||||
|
if (nextMw === undefined) {
|
||||||
|
history.push(next);
|
||||||
|
pages.push(new Page(mwm.getArticlePath(next), next, [], false));
|
||||||
|
if (history.length === 1)
|
||||||
|
throw new Error("Could not to connect to API. Is the URL correct? See the <b>About</b> section for more information.");
|
||||||
|
else
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
next = nextMw.normalize(next);
|
next = nextMw.normalize(next);
|
||||||
if (history.some(it => it.equals(next)))
|
if (history.some(it => it.equals(next)))
|
||||||
continue;
|
continue;
|
||||||
|
@ -596,7 +611,10 @@ export const discoverNetwork = async function (mwm, title, progressCb) {
|
||||||
|
|
||||||
// Normalize links
|
// Normalize links
|
||||||
pages.forEach(page => {
|
pages.forEach(page => {
|
||||||
page.langLinks = page.langLinks.map(langLink => mwm.getMw(langLink.lang).normalize(langLink));
|
page.langLinks = page.langLinks.map(langLink => {
|
||||||
|
const mw = mwm.getMw(langLink.lang);
|
||||||
|
return mw !== undefined ? mw.normalize(langLink) : langLink;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return {pages: pages, redirects: redirects};
|
return {pages: pages, redirects: redirects};
|
||||||
|
|
Loading…
Reference in New Issue