diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index b133ed221a..e0c3713388 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -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). diff --git a/lib/grape/endpoint.rb b/lib/grape/endpoint.rb index cbd318f458..3ec4ad3eb0 100644 --- a/lib/grape/endpoint.rb +++ b/lib/grape/endpoint.rb @@ -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 diff --git a/spec/grape/api_spec.rb b/spec/grape/api_spec.rb index 486b4b6ef4..78e9bc0f02 100644 --- a/spec/grape/api_spec.rb +++ b/spec/grape/api_spec.rb @@ -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'