Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoMethodError - undefined method '=~' for 1:Integer #1889

Closed
dentarg opened this issue Feb 26, 2023 · 1 comment · Fixed by #1890
Closed

NoMethodError - undefined method '=~' for 1:Integer #1889

dentarg opened this issue Feb 26, 2023 · 1 comment · Fixed by #1890
Labels

Comments

@dentarg
Copy link
Member

dentarg commented Feb 26, 2023

# config.ru
require "sinatra/base"

class App < Sinatra::Base
  get "/" do
    uri(1)
  end
end

run App
arm64 $ bundle exec puma
Puma starting in single mode...
* Puma version: 6.1.0 (ruby 3.2.1-p31) ("The Way Up")
*  Min threads: 0
*  Max threads: 5
*  Environment: development
*          PID: 59431
* Listening on http://0.0.0.0:9292
Use Ctrl-C to stop
2023-02-26 19:10:10 - NoMethodError - undefined method `=~' for 1:Integer:
	/Users/dentarg/src/sinatra/sinatra/lib/sinatra/base.rb:320:in `uri'
	config.ru:5:in `block in <class:App>'

sinatra/lib/sinatra/base.rb

Lines 317 to 334 in 50b8398

# 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
uri = [host = String.new]
if absolute
host << "http#{'s' if request.secure?}://"
host << if request.forwarded? || (request.port != (request.secure? ? 443 : 80))
request.host_with_port
else
request.host
end
end
uri << request.script_name.to_s if add_script_name
uri << (addr || request.path_info).to_s
File.join uri
end

@dentarg dentarg added the bug label Feb 26, 2023
@dentarg
Copy link
Member Author

dentarg commented Feb 26, 2023

Before 3.2.0, a warning was printed (if you ran with warnings enabled)

arm64 $ RUBYOPT=-W bundle exec puma
Puma starting in single mode...
* Puma version: 6.1.0 (ruby 3.1.3-p185) ("The Way Up")
*  Min threads: 0
*  Max threads: 5
*  Environment: development
*          PID: 60791
* Listening on http://0.0.0.0:9292
Use Ctrl-C to stop
/Users/dentarg/src/sinatra/sinatra/lib/sinatra/base.rb:320: warning: deprecated Object#=~ is called on Integer; it always returns nil

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant