Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

449
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda