Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Matching spaces with regex routes are broken in 1.3.1. This is a fix. #390

wants to merge 2 commits into


None yet
2 participants

niko commented Oct 18, 2011

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

rkh commented Dec 13, 2012

I am not sure about this. I actually like that regular expressions run on the input we get, allows you to differentiate cases you can't with the pattern.


rkh commented Dec 13, 2012

Also, you're the only one to complain so far.

@rkh rkh closed this Feb 26, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment