Today I noticed, that the description request fails for some events that have "Γ", "ΓΌ" or similar characters in them.
This results in the error "Too Many Redirects".
My Attempts To Fix This
I have tried upping the maxRedirects property of the Axios request but with no success.
I have played around with this function
axios.get("https://www.wowhead.com/de/event=634")
The URL Axios tries to request is the following:
https://www.wowhead.com/de/event=634/das-gro%C3%83%C2%9Fe-hippogryphenschl%C3%83%C2%BCpfen
which Axios does not seem to work with since this keeps redirecting. (It does work in a normal browser)
Though when I manually give Axios this URL (which i directly copied from my browser):
https://www.wowhead.com/de/event=634/das-gro%C3%9Fe-hippogryphenschl%C3%BCpfen
it does work.
Notice the additional %83%C2
which seems to break the code.
The Workaround
As you can see in my latest push 84733e0 for version v2.2.0 i have now implemented this workaround:
try {
let description = axios.get(`https://www.wowhead.com/${locale}/event=${JSON.parse(filteredResults[i].id)}`).then(({ data }) => {
let metaTag = data.match('<meta name="description" content="(?:.*)">', 'gi');
return metaTag[0].replace('<meta name="description" content="', '').replace('">', '');
});
// Add the description to the event object and push it to the activeEvents array
filteredResults[i].description = await description;
filteredResults[i].descriptionLocale = locale;
// Set a flag to indicate that the description request was successful and no fallback was used
filteredResults[i].descriptionFallback = false;
activeEvents.push(filteredResults[i]);
} catch {
//Fallback to "en" if the chosen description locale request results in too many redirects
let description = axios.get(`https://www.wowhead.com/en/event=${JSON.parse(filteredResults[i].id)}`).then(({ data }) => {
let metaTag = data.match('<meta name="description" content="(?:.*)">', 'gi');
return metaTag[0].replace('<meta name="description" content="', '').replace('">', '');
});
// Add the description to the event object and push it to the activeEvents array
filteredResults[i].description = await description;
filteredResults[i].descriptionLocale = "en";
// Set a flag to indicate that the description has been replaced with a fallback
filteredResults[i].descriptionFallback = true;
activeEvents.push(filteredResults[i]);
}
This workaround just falls back to "en" locale, which does not seem to have this Too Many Redirects issue (at least at this moment).
It also sets the flag descriptionFallback = true;
to indicate, that this description is a fallback to english.
Help Wanted!
I really want to get this working with all the different locales without issues and not with this sloppy workaround.
Maybe some of you reading this have better ideas than I have and can maybe help me with this issue.
I do appreciate everyone who creates a Pull Request to help me fix this bug.