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

Fix multi-method routes to append '(.:format)' only once #188

Merged
merged 2 commits into from
Jun 26, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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