kwhitley / itty-router

A little router.
MIT License
1.78k stars 78 forks source link

What exactly is supported path-wise? #43

Closed taralx closed 3 years ago

taralx commented 3 years ago

I'm trying to interpret some of the regex stuff in the tests, and I don't really understand it. Here's a few cases I think will help me understand better. For each one, should the path match the route or not?

route path
/x\|y /y
/x/y\|z /z
/x/y\|/z /x/z
/xy* /x
/xy* /xyz
/:x.y /a.x.y
/x.y /xay
/xy{2} /xyxy
/xy{2} /xy/xy
/:x.:y /a.b.c
/test.:x /test.a.b

Also, are these just errors, or should they have reasonable meanings?

kwhitley commented 3 years ago

Working up tests for each of these with explanations (of each)

kwhitley commented 3 years ago

There are definitely some nuances... in practice, itty supports very few regex patterns, aside from a few "happy little accidents", due to the nature of this all being regex-that-generates-regex (you lose most common patterns in translation without a lot of additional work/chars to escape everything).

kwhitley commented 3 years ago

Dang... glad you wrote these test cases up... easy enough to put them into the bulk route tester (with my expectations), where I found several of my expectations were not met... 😭

kwhitley commented 3 years ago

Gotta run an errand, but (without the explanations in code comments, here's the outcome... I'll take a stab at addressing that regex... there are a couple in here particularly worrisome (e.g. the last fail) image

kwhitley commented 3 years ago

And the last two look OK as well image

kwhitley commented 3 years ago

Extensive tests in the two (about to be) merged branches around your proposal document a bit more of the expected behavior. We should consider this addressed there - if you disagree, feel free to re-open!