Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

447
Views
In the if else statement if statement is always true and else block is not executed

In the console.log this statement "/es|ar|en/.test(window.location.pathname" is always true, even when the path does not include available languages of i18n and because of that the else block is not executed. The else block should be executed when the user inserts unavailable language, for example "ru" in the path and redirect to back. But when the pathname includes *"en", "es" or "ar" * after page reloading the user should be stay in the same page.With the include method i can check only one value, i want to check multiple ones.How can i check whether path includes languages or not in other way? or what i did wrong in the below statement?.

 useEffect(() => {
        if (/es|ar|en/.test(window.location.pathname)) {
            history.push(window.location.pathname)
        }
        else {
            history.goBack()

        }
    }, [window.location]);
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!