diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 51e1f3b1..dba98719 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2021-10-31 19:10:34 UTC using RuboCop version 1.22.3. +# on 2021-10-31 21:29:49 UTC using RuboCop version 1.22.3. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -109,12 +109,11 @@ Layout/EmptyLineBetweenDefs: - 'test/integration/consumer_test.rb' - 'test/units/test_net_http_client.rb' -# Offense count: 20 +# Offense count: 17 # Cop supports --auto-correct. Layout/EmptyLines: Exclude: - 'lib/oauth/cli/authorize_command.rb' - - 'lib/oauth/consumer.rb' - 'test/cases/oauth_case.rb' - 'test/cases/spec/1_0-final/test_construct_request_url.rb' - 'test/cases/spec/1_0-final/test_normalize_request_parameters.rb' @@ -404,7 +403,7 @@ Layout/SpaceInsideBlockBraces: - 'test/support/minitest_helpers.rb' - 'test/units/test_consumer.rb' -# Offense count: 450 +# Offense count: 452 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. # SupportedStyles: space, no_space, compact @@ -565,14 +564,14 @@ Metrics/AbcSize: # Offense count: 9 # Configuration parameters: CountComments, CountAsOne. Metrics/ClassLength: - Max: 277 + Max: 282 # Offense count: 7 # Configuration parameters: IgnoredMethods. Metrics/CyclomaticComplexity: Max: 18 -# Offense count: 64 +# Offense count: 65 # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. Metrics/MethodLength: Max: 45 @@ -585,7 +584,7 @@ Metrics/ParameterLists: # Offense count: 7 # Configuration parameters: IgnoredMethods. Metrics/PerceivedComplexity: - Max: 17 + Max: 18 # Offense count: 16 # Cop supports --auto-correct. @@ -833,7 +832,7 @@ Style/CommentAnnotation: - 'lib/oauth/tokens/request_token.rb' - 'test/units/test_action_controller_request_proxy.rb' -# Offense count: 7 +# Offense count: 6 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions. # SupportedStyles: assign_to_condition, assign_inside_condition @@ -916,7 +915,7 @@ Style/HashConversion: Exclude: - 'lib/oauth/tokens/request_token.rb' -# Offense count: 491 +# Offense count: 495 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys diff --git a/lib/oauth/consumer.rb b/lib/oauth/consumer.rb index a840f94c..0e578a52 100644 --- a/lib/oauth/consumer.rb +++ b/lib/oauth/consumer.rb @@ -343,18 +343,22 @@ def proxy # Instantiates the http object def create_http(_url = nil) - if !request_endpoint.nil? _url = request_endpoint end - - if _url.nil? || _url[0] =~ /^\// - our_uri = URI.parse(site) - else - our_uri = URI.parse(_url) - end - + our_uri = if _url.nil? || _url[0] =~ /^\// + URI.parse(site) + else + your_uri = URI.parse(_url) + if your_uri.host.nil? + # If the _url is a path, missing the leading slash, then it won't have a host, + # and our_uri *must* have a host, so we parse site instead. + URI.parse(site) + else + your_uri + end + end if proxy.nil? http_object = Net::HTTP.new(our_uri.host, our_uri.port)