lapis icon indicating copy to clipboard operation
lapis copied to clipboard

Specify what parameter character classes are supported in documentation?

Open TangentFoxy opened this issue 6 years ago • 2 comments
trafficstars

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.

TangentFoxy avatar Jun 13 '19 16:06 TangentFoxy

@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.

TangentFoxy avatar Apr 29 '20 10:04 TangentFoxy

%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

leafo avatar Apr 30 '20 21:04 leafo