You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the fix on push method work on all the url, even on the domain part and not only on the path
push(newUrl){leturl=newUrl// We need to do this because there's an error when using i18n on the root path// it says for example `pages/fr.js` doesn't existif(singletonRouter.locale){url=url.replace(`/${singletonRouter.locale}`,'');}// No need to provide the second argument, Next.js will know what to dosingletonRouter.push(url,undefined,{shallow: true,})},
if the url is something like https://it.mydomain.eu/product with the locale part in third level domain, it will replace the url to https://.mydomain.eu/product
push(newUrl){leturl=newUrl// We need to do this because there's an error when using i18n on the root path// it says for example `pages/fr.js` doesn't existif(singletonRouter.locale){url=url.replace(newRegExp(`(?<=^https?:\/\/[^\/]+)\/${singletonRouter.locale}(?=\/|$)`,'i'),'');}// No need to provide the second argument, Next.js will know what to dosingletonRouter.push(url,undefined,{shallow: true,})},
Package version
7.3.0
Operating system
No response
Browser
No response
Code of Conduct
I agree to follow this project's Code of Conduct
The text was updated successfully, but these errors were encountered:
Instead of the hardcoded fix, is there a way to get the i18n configuration of Next so we can use that as the source of truth? it's indeed also possible that you're using the locale somewhere else in the url and don't want that replaced
🐛 Current behavior
the fix on push method work on all the url, even on the domain part and not only on the path
if the url is something like
https://it.mydomain.eu/product
with the locale part in third level domain, it will replace the url tohttps://.mydomain.eu/product
🔍 Steps to reproduce
Live reproduction
unable to reproduce on codesandbox
💭 Expected behavior
should only replace the path part
Possibile Solution
you can try with a regex like this: https://regex101.com/r/U8mzbj/1
Package version
7.3.0
Operating system
No response
Browser
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: