Avoid crash in `uri` helper on Integer input (#1890)
Ruby 3.2.0 removed Object#=~ in https://github.com/ruby/ruby/pull/5383
Has been deprecated since Ruby 2.6.0:
ebff9dc10e
https://bugs.ruby-lang.org/issues/15231
This commit is contained in:
parent
50b8398dd7
commit
892cbeb378
|
@ -317,7 +317,7 @@ module Sinatra
|
|||
# Generates the absolute URI for a given path in the app.
|
||||
# Takes Rack routers and reverse proxies into account.
|
||||
def uri(addr = nil, absolute = true, add_script_name = true)
|
||||
return addr if addr =~ /\A[a-z][a-z0-9+.\-]*:/i
|
||||
return addr if addr.to_s =~ /\A[a-z][a-z0-9+.\-]*:/i
|
||||
|
||||
uri = [host = String.new]
|
||||
if absolute
|
||||
|
|
|
@ -1845,6 +1845,12 @@ class HelpersTest < Minitest::Test
|
|||
assert_equal 'http://example.org/foo/bar', body
|
||||
end
|
||||
|
||||
it 'handles integer input' do
|
||||
mock_app { get('/') { uri 123 }}
|
||||
get '/'
|
||||
assert_equal 'http://example.org/123', body
|
||||
end
|
||||
|
||||
it 'handles absolute URIs' do
|
||||
mock_app { get('/') { uri 'http://google.com' }}
|
||||
get '/'
|
||||
|
|
Loading…
Reference in New Issue