Le 18/01/2011 11:47, Alexis Sukrieh a écrit :
Le 18/01/2011 11:40, sawyer x a écrit :
But at first glance I don't see where they handle that conditional token...
Line 1081?
Well, I don't think so, let's investigate with irb:
I've copied the build method in a dumb class (TestRegexp) in order to play with it, because I don't feel like parsing all that ruby code with my brain ;)
First of all a simple case: what does "/test" ends up with:
irb(main):002:0> TestRegexp.compile('/test') => [/^\/test$/, []]
OK, fair enough, pretty the same at what Dancer builds.
Now, what happens with a question mark:
irb(main):003:0> TestRegexp.compile('/test?') => [/^\/test?$/, []]
Well, nothing more...
OK, my bad ;) Here it is: irb(main):004:0> TestRegexp.compile('/test/(:id)?') => [/^\/test\/\(([^\/?#]+)\)?$/, ["id"]] Looks like there is nothing to do actually, the quotation mark is kepts as is and that ends up with a valid regexp, with the capture being optional. Dancer should definitely behave the same (but is not)...