From 54edcf793b28445e8bed43ad4c508c8b9c6f5afe Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Wed, 13 Oct 2021 11:34:25 +0200 Subject: [PATCH] Handle redirects --- Logic/Web/Wikidata.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Logic/Web/Wikidata.ts b/Logic/Web/Wikidata.ts index 4c9fd5081..571d94859 100644 --- a/Logic/Web/Wikidata.ts +++ b/Logic/Web/Wikidata.ts @@ -295,7 +295,9 @@ export default class Wikidata { } const url = "https://www.wikidata.org/wiki/Special:EntityData/" + id + ".json"; - const response = (await Utils.downloadJson(url)).entities[id] + const entities = (await Utils.downloadJson(url)).entities + const firstKey = Array.from(Object.keys(entities))[0] // Roundabout way to fetch the entity; it might have been a redirect + const response = entities[firstKey] if (id.startsWith("L")) { // This is a lexeme: