Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect translation of external links #55

Open
simonhenke opened this issue Dec 7, 2022 · 4 comments
Open

Incorrect translation of external links #55

simonhenke opened this issue Dec 7, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@simonhenke
Copy link

Some version between 1.8.0-1 and 1.9.1 now causes external links to be translated incorrectly:
I'm passing a href like
https://www.dhl.com/de-de/home/tracking/tracking-express.html
and the lib parses it to
/de-de/home/tracking/tracking-express.html

My current workaround is something like
const Link = href.toString().startsWith("http") ? NextLink : NextTranslateRoutesLink;
which I then render in a custom component.

But it would be better if the next-translate-routes wouldn't translate external links.

@cvolant
Copy link
Collaborator

cvolant commented Jan 20, 2023

Yes, it should not. Seems like a bug the tests did not catch.

@cvolant cvolant added the bug Something isn't working label Jan 20, 2023
@ctrichereau
Copy link

Hey guys !

We have some similar issues with our project.
Our config :

  • next V12.3.1
  • next-translate-routes V1.8.0

We pass this url as href :
https://www.domain.com/fr/this-website-part
and the lib parse it to this url :
https://www.domain.com/fr/frhttps:/www.domain.com/this-website-part/

We use the tips from @simonhenke for prevent this problem and it's working well.

Thanks in advance !

@cvolant
Copy link
Collaborator

cvolant commented Feb 21, 2023

Until now, next-translate-routes tries to match any url pathname with a local page. If it fails to do so, it returns use the raw url as is. The problem is that an external url pathname can match a local page, especially if you use match all pages.

So we need to add a domain check, but it is not that easy because there could be several local domain depending on the locale.
Cf. https://nextjs.org/docs/advanced-features/i18n-routing#domain-routing

So we need to fix this issue first.

@ctrichereau
Copy link

Thanks @cvolant for the answer.
We will wait for updates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants