Skip to content

Commit ad79137

Browse files
committed
Merge pull request #188 from kainosnoema/fix-multi-method-paths
Fix multi-method routes to append '(.:format)' only once
2 parents 9013459 + 74feb87 commit ad79137

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

CHANGELOG.markdown

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Next Release
22
============
33

4+
* [#188](https://github.com/intridea/grape/pull/188): Fix: multi-method routes should append '(.:format)' only once - [@kainosnoema](https://github.com/kainosnoema).
45
* [#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).
56
* [#175](https://github.com/intridea/grape/pull/175): Added support for API versioning based on a request parameter - [@jackcasey](https://github.com/jackcasey).
67
* [#168](https://github.com/intridea/grape/pull/168): Fix: Formatter can parse symbol keys in the headers hash - [@netmask](https://github.com/netmask).

lib/grape/endpoint.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ def prepare_path(path)
8585
parts << ':version' if settings[:version] && settings[:version_options][:using] == :path
8686
parts << namespace.to_s if namespace
8787
parts << path.to_s if path && '/' != path
88-
parts.last << '(.:format)'
89-
Rack::Mount::Utils.normalize_path(parts.join('/'))
88+
Rack::Mount::Utils.normalize_path(parts.join('/') + '(.:format)')
9089
end
9190

9291
def namespace

spec/grape/api_spec.rb

+4
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,10 @@ def app; subject end
230230
"hiya"
231231
end
232232

233+
subject.endpoints.first.routes.each do |route|
234+
route.route_path.should eql '/abc(.:format)'
235+
end
236+
233237
get '/abc'
234238
last_response.body.should eql 'hiya'
235239
post '/abc'

0 commit comments

Comments
 (0)