Skip to content

Commit 316d863

Browse files
author
Michael Bleigh
committed
Fix Strexp compile expression to use '.' as a separator.
1 parent 744c7fc commit 316d863

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/grape/api.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def route(methods, paths, &block)
185185

186186
methods.each do |method|
187187
paths.each do |path|
188-
path = Rack::Mount::Strexp.compile(compile_path(path), options, ['/'], true)
188+
path = Rack::Mount::Strexp.compile(compile_path(path), options, %w( / . ? ), true)
189189
route_set.add_route(endpoint,
190190
:path_info => path,
191191
:request_method => (method.to_s.upcase unless method == :any)

spec/grape/api_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,15 @@ def app; subject end
190190
last_response.body.should eql '"json"'
191191
end
192192

193+
it 'should allow for format without corrupting a param' do
194+
subject.get('/:id') do
195+
params[:id]
196+
end
197+
198+
get '/awesome.json'
199+
last_response.body.should eql "\"awesome\""
200+
end
201+
193202
it 'should allow for format in namespace with no path' do
194203
subject.namespace :abc do
195204
get do

0 commit comments

Comments
 (0)