lapis
lapis copied to clipboard
Specify what parameter character classes are supported in documentation?
From the docs, I naively assumed that any Lua pattern could be used, or at least the built-in ones and maybe a little more, leading to an attempt to use %u:
[tracks: "/tracks(/:order[%u])(/:asc_desc)(/:page[%d])"]: =>
Looking at the code, it is clear why this doesn't work, but I would ask for some clarification in the docs about what exactly works or doesn't.
@leafo I'd like to ask, since I don't understand LPeg, if you could clarify exactly what patterns can be used in parameter character classes. I'd be happy to submit a pull request with updated docs if only I understood it myself.
%a %d %w (as defined by Lua) and then any range specified with a dash like A-Z
Optionally a ^ can be included in front to negate the set. Additional character classes can be listed and they will be unioned (for example, A-Za-z is valid)
Code here: https://github.com/leafo/lapis/blob/master/lapis/router.moon#L105