Skip to content

Commit

Permalink
Merge pull request #188 from kainosnoema/fix-multi-method-paths
Browse files Browse the repository at this point in the history
Fix multi-method routes to append '(.:format)' only once
  • Loading branch information
dblock committed Jun 26, 2012
2 parents 9013459 + 74feb87 commit ad79137
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.markdown
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Next Release
============

* [#188](https://github.com/intridea/grape/pull/188): Fix: multi-method routes should append '(.:format)' only once - [@kainosnoema](https://github.com/kainosnoema).
* [#64](https://github.com/intridea/grape/issues/64), [#180](https://github.com/intridea/grape/pull/180): Added support to get request bodies as parameters - [@bobbytables](https://github.com/bobbytables).
* [#175](https://github.com/intridea/grape/pull/175): Added support for API versioning based on a request parameter - [@jackcasey](https://github.com/jackcasey).
* [#168](https://github.com/intridea/grape/pull/168): Fix: Formatter can parse symbol keys in the headers hash - [@netmask](https://github.com/netmask).
Expand Down
3 changes: 1 addition & 2 deletions lib/grape/endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ def prepare_path(path)
parts << ':version' if settings[:version] && settings[:version_options][:using] == :path
parts << namespace.to_s if namespace
parts << path.to_s if path && '/' != path
parts.last << '(.:format)'
Rack::Mount::Utils.normalize_path(parts.join('/'))
Rack::Mount::Utils.normalize_path(parts.join('/') + '(.:format)')
end

def namespace
Expand Down
4 changes: 4 additions & 0 deletions spec/grape/api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ def app; subject end
"hiya"
end

subject.endpoints.first.routes.each do |route|
route.route_path.should eql '/abc(.:format)'
end

get '/abc'
last_response.body.should eql 'hiya'
post '/abc'
Expand Down

0 comments on commit ad79137

Please sign in to comment.