You can clone with
HTTPS or Subversion.
Per SO question (http://stackoverflow.com/questions/9775591/required-and-optional-parameters-for-sinatra-route) it would be useful to have required and optional parameters in route strings for things like adding ".json" to a resource id to build a JSON response.
This works fine:
But, this currently does not:
If you pass 'abc.json' to that it, the :id parameter will be 'abc.json' and the format parameter will be empty.
The compiled regex appears to be:
The "." is not part of the exclusion in the first group, so it doesn't stop there as it would for a "/" or "#".
I did get past this by going full regex on the route and excluding the "." from the first regex group. But, this seems like a fairly common use case that would be helpful to support in regular route strings.
Discussion about possible solutions: https://gist.github.com/2154980
+1 This issue is biting me, too. The Sinatra DSL should handle format extensions such as .xml, .json, and so forth in a sensible and consistent way.
Reading through the discussion in https://gist.github.com/2154980 and subsequently in #492, shouldn't this be fixed with 762967f?
Does any official Sinatra release include this fix? I see that 1.3.3 is the latest, but this issue is listed as Milestone 1.4.0.
In the meantime, should we apply a similar workaround that the SO poster tried? How did he generate the compiled Sinatra regex from the route?
@omnilinguist you could also just run against Sinatra master. I'll see that I can prep a release soon.