-
-
Notifications
You must be signed in to change notification settings - Fork 267
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
Not adding the leading slash leads to an anonymous NoMethodError: undefined method `downcase' for nil:NilClass #194
Comments
Hello, been through this problem too. When playing with auth with the Twitter API: The problem lies in the def request(http_method, path, token = nil, request_options = {}, *arguments)
if path !~ /^\//
@http = create_http(path) # we go here if no leading slash Which leads us to (same file): def create_http(_url = nil)
. . .
if _url.nil? || _url[0] =~ /^\//
our_uri = URI.parse(site)
else
our_uri = URI.parse(_url) # we are here since url[0] is not a "/"
end So, instead of parsing something like All the way down, we hit (file def normalized_uri
"#{u.scheme.downcase}://#{u.host.downcase} # since u.host is nil, raise Error I am not sure why, we would parse a path if it does not begin with a slash. |
Thanks for the report @ferdi2005 , and the analysis @cyrillefr . I'll work on fixing this issue for the next release, which will be at least a minor bump. |
Signed-off-by: Peter Boling <peter.boling@gmail.com>
…sh-error 🐛 Fix #194: NoMethodError on missing leading slash
Signed-off-by: Peter Boling <peter.boling@gmail.com>
Not adding the traling slash in the OAuth consumer leads to an uneasily debuggable
NoMethodError: undefined method 'downcase' for nil:NilClass
Example, using:
oauth_consumer = OAuth::Consumer.new(ENV["CONSUMER_KEY"], ENV["CONSUMER_SECRET"], :site => "https://commons.wikimedia.org", :request_token_path => "w/index.php?title=Special:OAuth/initiate", :authorize_path => "wiki/Special:OAuth/authorize", :access_token_path => "wiki/Special:OAuth/token",)
instead of:
oauth_consumer = OAuth::Consumer.new(ENV["CONSUMER_KEY"], ENV["CONSUMER_SECRET"], :site => "https://commons.wikimedia.org", :request_token_path => "/w/index.php?title=Special:OAuth/initiate", :authorize_path => "/wiki/Special:OAuth/authorize", :access_token_path => "/wiki/Special:OAuth/token",)
leads to a
NoMethodError: undefined method 'downcase' for nil:NilClass
and not to a clearer error.The text was updated successfully, but these errors were encountered: