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

Routing does not match url-encoded path #262

Closed
PaulRivier opened this issue May 3, 2020 · 5 comments
Closed

Routing does not match url-encoded path #262

PaulRivier opened this issue May 3, 2020 · 5 comments
Labels
bug info needed More information is needed test needed

Comments

@PaulRivier
Copy link

Hi there,

I can not find a way to match an URL encoded path such as /page/P%C3%A2tes
It seems to fail with both capture pattern, placeholders and regex.

Is this a bug ?

@chessai
Copy link
Contributor

chessai commented May 3, 2020 via email

@PaulRivier
Copy link
Author

Hello, thank you for your quick reply.

I messed my test cases before posting my original message, sorry about that. This is a more proper report, thank you for caring.

This works and matches /page/Pâtes

get "/page/:page" $ do
  p <- param "page"
  servePage p

But I need to match the rest of the url after page, not only first segment, so /page/recette/Pâtes would match with path=recette/Pâtes. I could not find a clean way to get this behaviour, so I used the regex feature.

My regex is something like :

get (regex "^/page/(.+)")
  p <- param "1"
  servePage p

It does match correctly /page/Hello, but it is buggy on /page/Pâtes. Basically, it will only match "P".

Interestingly, if regexp ends with "$" (like "^/page/(.+)$"), it does not match at all accentuated words.

Maybe the regex feature has some issues with multibytes chars.

I would appreciate a lot to have a pattern to match the remaining of the path, like "/page/:~page" or so.

Thank you.

@ocramz
Copy link
Collaborator

ocramz commented Oct 3, 2023

@PaulRivier url-decoding parameters looks buggy indeed

@ocramz
Copy link
Collaborator

ocramz commented Dec 17, 2023

As pointed out by @jfraudeau this is indeed fixed by #302

@ocramz ocramz closed this as completed Dec 17, 2023
@PaulRivier
Copy link
Author

PaulRivier commented Dec 17, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug info needed More information is needed test needed
Projects
None yet
Development

No branches or pull requests

3 participants