Skip to content

Commit

Permalink
Fix #174: the value of PATH_INFO is no longer modified during request.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Jan 5, 2013
1 parent 51aa546 commit b44cd8d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* [#172](https://github.com/intridea/grape/issues/172): Fix: MultiJson deprecated methods warnings - [@dblock](https://github.com/dblock).
* [#293](https://github.com/intridea/grape/pull/293): Added options to `cookies.delete`, enables passing a path - [@inst](https://github.com/inst).
* [#133](https://github.com/intridea/grape/issues/133): Fix: header-based versioning with use of `prefix` - [@seanmoon](https://github.com/seanmoon), [@dblock](https://github.com/dblock).
* [#133](https://github.com/intridea/grape/issues/133): The value of `env['PATH_INFO']` is no longer altered with `path` versioning - [@dblock](https://github.com/dblock).
* [#174](https://github.com/intridea/grape/issues/174): The value of `env['PATH_INFO']` is no longer altered with `path` versioning - [@dblock](https://github.com/dblock).
* [#280](https://github.com/intridea/grape/issues/280): Fix: grouped parameters mangled in `route_params` hash - [@marcusg](https://github.com/marcusg), [@dblock](https://github.com/dblock).
* [#304](https://github.com/intridea/grape/issues/304): Fix: `present x, :with => Entity` returns class references with `format :json` - [@dblock](https://github.com/dblock).
* [#196](https://github.com/intridea/grape/issues/196): Fix: root requests don't work with `prefix` - [@dblock](https://github.com/dblock).
Expand Down
2 changes: 1 addition & 1 deletion lib/grape/middleware/versioner/path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def default_options
end

def before
path = env['PATH_INFO']
path = env['PATH_INFO'].dup

if prefix && path.index(prefix) == 0
path.sub!(prefix, '')
Expand Down
28 changes: 28 additions & 0 deletions spec/grape/endpoint_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -579,4 +579,32 @@ def initialize(id)
end
end
end

context 'request' do
it 'should be set to the url requested' do
subject.get('/url') do
request.url
end
get '/url'
last_response.body.should == "http://example.org/url"
end
it 'should include version' do
subject.version 'v1', :using => :path
subject.get('/url') do
request.url
end
get '/v1/url'
last_response.body.should == "http://example.org/v1/url"
end
it 'should include prefix' do
subject.version 'v1', :using => :path
subject.prefix 'api'
subject.get('/url') do
request.url
end
get '/api/v1/url'
last_response.body.should == "http://example.org/api/v1/url"
end
end

end

0 comments on commit b44cd8d

Please sign in to comment.