Giter Club home page Giter Club logo

wow-calendar.js's People

Stargazers

Chambrin avatar Joshua Harms avatar

Watchers

RootK1d avatar

Forkers

dominicabrooks

wow-calendar.js's Issues

getActiveEvents("de") - Error: Too Many Redirects

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.