mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
Merge pull request #605 from foca/master
Allow URI objects as redirect targets
This commit is contained in:
commit
9984d0d2b3
2 changed files with 12 additions and 1 deletions
|
@ -173,7 +173,7 @@ module Sinatra
|
|||
|
||||
# According to RFC 2616 section 14.30, "the field value consists of a
|
||||
# single absolute URI"
|
||||
response['Location'] = uri(uri, settings.absolute_redirects?, settings.prefixed_redirects?)
|
||||
response['Location'] = uri(uri.to_s, settings.absolute_redirects?, settings.prefixed_redirects?)
|
||||
halt(*args)
|
||||
end
|
||||
|
||||
|
|
|
@ -240,6 +240,17 @@ class HelpersTest < Test::Unit::TestCase
|
|||
assert_equal '', body
|
||||
assert_equal 'mailto:jsmith@example.com', response['Location']
|
||||
end
|
||||
|
||||
it 'accepts a URI object instead of a String' do
|
||||
mock_app do
|
||||
get('/') { redirect URI.parse('http://sinatrarb.com') }
|
||||
end
|
||||
|
||||
get '/'
|
||||
assert_equal 302, status
|
||||
assert_equal '', body
|
||||
assert_equal 'http://sinatrarb.com', response['Location']
|
||||
end
|
||||
end
|
||||
|
||||
describe 'error' do
|
||||
|
|
Loading…
Reference in a new issue