sinatra/sinatra — pull request #390 by niko (2011-10-18 21:29:58+00:00)
Title: Matching spaces with regex routes are broken in 1.3.1. This is a fix.

Presumably when introducing the ability to pass url encoded parameters within a URL the ability to match URLs with a regex containing spaces got lost. This must have been between 1.2.6 and 1.3.1 as this used to work in 1.2.6.

This patch makes regex routes with spaces working again. Also, umlauts (and perhaps other stuff that got url encoded in routing) now works again for regex routes. I ran the test suite with 1.9.2 and 1.8.7.

The price to pay is what I called "%2F shuffle" in the route matching. Considering that the slash is our route separator I think it deserves the extra treatment.

Still not working are regex routes with slashes in the regex (like get %r{\A/([\w\/]+)} do ...). I added a test case for this but it is commented out. I'm not sure at all how this should (or even could) be handled.

The alternative to this or a similar patch would be (IMHO) that regex routes loose their first class citizenship in sinatra. As a user I'd expect to be

```
get '/foo/:bar' do
pass unless params[:bar] =~ /[\w ]+/
...
```
somewhat equivalent to

```
get %r{/foo/([\w ]+)' do
...
```