Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

448
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda