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

URL encoded characters when use 'prefix_and_default' #1792

Closed
szwenni opened this issue Jan 12, 2023 · 6 comments · Fixed by #1816
Closed

URL encoded characters when use 'prefix_and_default' #1792

szwenni opened this issue Jan 12, 2023 · 6 comments · Fixed by #1816
Labels
help wanted 🔨 p3-minor-bug Priority 3: a bug in an edge case that only affects very specific usage v8

Comments

@szwenni
Copy link
Contributor

szwenni commented Jan 12, 2023

Environment

  • Operating System: Darwin
  • Node Version: v16.16.0
  • Nuxt Version: 3.0.0
  • Nitro Version: 1.0.0
  • Package Manager: [email protected]
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

latest i18n nuxtjs module

Reproduction

Create a project with nuxtjs/i18n and create a page like [name].vue,
Strategy must be 'prefix_and_default' and at least two locales should be created

Now call the url with /äütest123

You will end up in a endless redirect loop

Describe the bug

A endless redirect loop when the URL contains special characters

Related code path:

if (isString(routePath) && routePath && routePath !== fullPath && !routePath.startsWith('//')) {

As you can see from the log, routePath and fullPath are different but if encode/decode both they result in being the same

Right now they are different which leads to redirect loops

Additional context

No response

Logs

detectRedirect: route ->  {                                                                                                   12:57:43
  fullPath: '/news/hoffnungsschimmer-kriegen-ftx-glaeubiger-ihr-geld-zurueck%C3%A4',
  hash: '',
  query: {},
  name: 'news-name___de___default',
  path: '/news/hoffnungsschimmer-kriegen-ftx-glaeubiger-ihr-geld-zurueck%C3%A4',
  params: {
    name: 'hoffnungsschimmer-kriegen-ftx-glaeubiger-ihr-geld-zurueckä'
  },
  matched: [
    {
      path: '/news/:name',
      redirect: undefined,
      name: 'news-name___de___default',
      meta: {},
      aliasOf: undefined,
      beforeEnter: undefined,
      props: [Object],
      children: [],
      instances: {},
      leaveGuards: Set(0) {},
      updateGuards: Set(0) {},
      enterCallbacks: {},
      components: [Object]
    }
  ],
  meta: {},
  redirectedFrom: undefined,
  href: '/news/hoffnungsschimmer-kriegen-ftx-glaeubiger-ihr-geld-zurueck%C3%A4'
}
detectRedirect: calculate routePath ->  /news/hoffnungsschimmer-kriegen-ftx-glaeubiger-ihr-geld-zurueckä /news/hoffnungsschimmer-kriegen-ftx-glaeubiger-ihr-geld-zurueck%C3%A4
@ineshbose
Copy link
Collaborator

Hi, thanks for opening an issue and providing the steps for reproduction. It would be a great help if you could provide a StackBlitz link (using https://stackblitz.com/github/nuxt/starter/tree/v3-stackblitz) with the same steps if possible to immediately get on debugging please!

@szwenni
Copy link
Contributor Author

szwenni commented Jan 12, 2023

Hi,

I triggered the same error in stackblitz here.

https://stackblitz.com/edit/github-kvhg77?file=pages/[name].vue

The links on home are on purpose a a tag to force i18n to initialize again.

BR,
Sven

@szwenni
Copy link
Contributor Author

szwenni commented Jan 13, 2023

Any updates here ? If it is easier I can try to create a pull rewuest with how I would imagine it to work.

@kazupon kazupon added 🔨 p3-minor-bug Priority 3: a bug in an edge case that only affects very specific usage help wanted and removed pending triage labels Jan 20, 2023 — with Volta.net
Copy link
Collaborator

kazupon commented Jan 20, 2023

@szwenni
Thank you for your reproting!
Sorry, late my reply.

Of course we welcome any PR from community!

@szwenni
Copy link
Contributor Author

szwenni commented Jan 24, 2023

Hi,
just for completness:
This happens with every character in the URL which is encoded by the browser. So whitespaces or any UTF-8 character.
I'm trying to write a fix but that is quite a big impact. I know it is just with this strategy but from my point of view this could potential affect a lot of pages, especially news pages where whitespaces in URLs are daily business. Or languages which use UTF-8 signs more heavily than the german language.

@szwenni
Copy link
Contributor Author

szwenni commented Jan 24, 2023

Pull request created

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted 🔨 p3-minor-bug Priority 3: a bug in an edge case that only affects very specific usage v8
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants