route-recognizer icon indicating copy to clipboard operation
route-recognizer copied to clipboard

Library does not properly decode dynamic segment from utf-8 route

Open estshy opened this issue 6 years ago • 4 comments

this.route('worker', {
  path: 'praca-sprzątanie'
}, function () {
  this.route('city', {
    path: 'kczewo'
  });
});

When going on praca-sprzątanie/kczewo, route is properly recognized but dynamic segement is passed down as null. Code does behave correctly with ENCODE_AND_DECODE_PATH_SEGMENTS turned off.

image image image

Problem comes down to fact that originalPath is not decoded anyhow but later on it's used inside regular expression.

Is there any way to overwrite ENCODE_AND_DECODE_PATH_SEGMENTS flag from ember application till the issue will be resolved?

Issue was observed on ember 3.4.0

estshy avatar Sep 14 '18 12:09 estshy

@estshy - Can you attempt to submit a failing test case for this? It would almost certainly make fixing much easier...

@bantic - Sorry to pester you here, but I recall you fixing a few related issues here a while back and was wondering if you happen to have a pointer to where to start digging?

rwjblue avatar Nov 27 '18 02:11 rwjblue

@rwjblue No worries, thanks for the ping. I'll take a look at this and give some ideas.

bantic avatar Nov 28 '18 17:11 bantic

@estshy Can you give some more details to help reproduce the issue you're seeing?

this.route('worker', {
  path: 'praca-sprzątanie'
}, function () {
  this.route('city', {
    path: 'kczewo'
  });
});

This router snippet that you provided above doesn't have any dynamic segments. It instructs the router to recognize the static path "/praca-sprzątanie/kczewo". This static path seems to work fine. Here's a Twiddle that shows it working. Clicking the link (or pasting in the path directly to the twiddle's address bar) correctly takes you to the worker/city route and displays the template.

I created a second twiddle that has a dynamic segment for worker and city. It also appears to recognize your path ok. Clicking the link (or pasting path in directly) takes you to the worker/city route with the worker and city dynamic segments properly populated.

Let me know if I misunderstood the issue that you ran into.

bantic avatar Nov 29 '18 17:11 bantic

@bantic At the moment I am not able to reproduce the issue on twiddle and I am not sure why. I will get back to you with a failing test case when I will have more time to dig into it. For now I made workaround by extracting the missing parameter from url manually.

estshy avatar Dec 04 '18 09:12 estshy