Closed jirutka closed 8 years ago
@leafo gentle ping
Sorry for the late response, been a little busy (as always).
There are some issues with how you did the splat matching. The splat is way too greedy, and also moonscript style routes have no guaranteed ordering, so you'll get some funky results
Here are a few examples:
http://localhost.com:8080/manifest/hello
renders 200, should be 404
http://localhost.com:8080/manifestfefefe
renders 200, matches /manfest*
, but should be 400
http://localhost.com:8080/manifests/leafo/manifest
matches /manifest*
instead of my manifest
Uh, then I really don’t know how to implement this properly on Lapis. :( It lacks optional parameters.
alright, I can make the patch then
What if I replace e.g. /manifest*
with /manifest:rest
and @params.spread
with @params.rest
, would it work better…? However, it’s perhaps even uglier workaround than spread.
That sounds like it would work
http://localhost.com:8080/manifest/hello renders 200, should be 404 http://localhost.com:8080/manifestfefefe renders 200, matches /manfest*, but should be 400
This should actually work correctly, but I’ve messed the following line:
if not valid_format @format or splat_rest == ""
The second part of the condition is wrong, there should be splat_rest ~= ""
. However, it’s still wrong, because… omitting braces is sometimes tricky… It should be:
if not valid_format(@format) or splat_rest ~= ""
Sorry for this mistake.
http://localhost.com:8080/manifests/leafo/manifest matches /manifest* instead of my manifest
This problem is indeed caused by greedy behaviour of the splat operator.
I’ve fixed the mentioned problems, so please give it a second try.
looks like we missed one, the url /manifests
should match this page: https://luarocks.org/manifests I added a bunch of specs identifying pages that shouldn't match.
I know this routing stuff is a pain, I opened an issue leafo/lapis#384 to help fix these problems.
I'm just going to patch lapis for this, to give precedence to routes that match exactly
manually merged in after some updates, thanks for the patch
To be more specific, the following resources has been added: