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]);