Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 2 commits into from

Conversation

niko
Copy link

@niko 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
Copy link
Member

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
Copy link
Member

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
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants