-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Period in URL? #158
Comments
I wrote a quick sinatra app that shows you case, and Sinatra also does not handle parsing this case. require 'sinatra'
# GET /users/foo@bar.com returns not found
get '/users/:email' do
puts params[:email]
end On the other hand, rails seems to handle this case. I'd be happy to merge a pull request if you'd like to investigate how Rails handles this case. In the meantime, if you change your route and specify the email as a query parameter instead of part of the route, it works as you'd expect class API < Grape::API
# GET /users?email=foo@bar.com
get '/users' do
puts params[:email]
end
end I might take a look this evening to see if there's an easy fix involved. |
Regarding your Sinatra example, I'm not sure what's going on. I had to try your simple example since in my code I inherit from Sinatra::Base and use some other gems thinking they may affect why it's working for me, but it still works? require 'bundler/setup'
require 'sinatra'
get '/user/:email' do
params[:email]
end I've tried it in Chrome and FF on OSX and here's a curl from the terminal: It's not giving me a not found. Using Sinatra 1.3.2 |
I did some poking around in the Rails routing layer and it appears that they use the Journey Library for all their route parsing needs whereas Grape is relying on Edit: Clarified dependency on Rack::Mount. |
@SegFaultAX I heard about journey, but haven't dug into it at all since there's no real docs for it. My guess is that the |
Perhaps this is where the magic is happening? https://github.com/rails/journey/blob/master/lib/journey/router.rb#L125 |
@bobbytables That's where the route is actually being matched but unless I'm much mistaken what we need is to modify the generated regex used in that comparison to include the OP's desired functionality. That step happens when the endpoint is actually being built. In other words, the named capture group "foo" generated for path "/:foo" does not currently match valid email meta-characters (eg . and @). Does that sound about right @jch and @gaiottino? |
Correct On Tuesday 3 April 2012 at 22:42, Michael-Keith Bernard wrote:
|
Hello, I read this and know the period issue was fixed by the PR #159 . But it doesn't seem to work if I add another param after the email. (I am using the latest Grape 0.7.0) This is the sample code: get 'calendars/:email/:id' do
"123"
end when I hit If I remove the period from url, it returns 200 OK: Any thought? |
Oops, by checking the test on get 'calendars/:email/:id', :requirements => { :email => /YOUR_REGEXP_HERE/i } do
"123"
end |
Hi there,
Really liking Grape so far. I'm converting a Sinatra app to Grape and I've got a couple of questions:
How can I solve these issues?
The text was updated successfully, but these errors were encountered: