0

I'm using the following path definition:

router.get( '/tags/:tag([a-zA-Z0-9é]+)', ( req, res ) => { /.../ });

for

http://localhost/tags/ombré

But the :tag variable gets truncated and req.params.tag simply returns ombr

What's the correct regex to allow for an accented character or even multiple accented characters?

Thank you.

SFB
  • 1
  • 2
  • You could have searched at least once, you know. – Tomalak Oct 29 '17 at 20:20
  • I appreciate your comment. I did search and that answer didn't work for me. Can you offer an answer or suggestion for my example, Señor @Tomalak? – SFB Oct 29 '17 at 20:29
  • It's not that you should copy the other answer. It's that you should recognize the fact that the character `è` can not exist in URLs. And once you recognize that, you will know what to do. – Tomalak Oct 29 '17 at 20:32
  • I "should" but didn't catch that part. Maybe you could've pointed me to this question? https://stackoverflow.com/questions/1386262/should-i-use-accented-characters-in-urls – SFB Oct 29 '17 at 20:35
  • There are various ways to try to hack around this but, if it were me, I think I would remove the validation from the route path and instead perform this check inside the first route handler. If you're chaining handlers then you can use `next('route')` to skip them all in the event that validation fails. – skirtle Oct 29 '17 at 20:37

0 Answers0