lib/excon/addressable.rb in excon-addressable-0.1.0 vs lib/excon/addressable.rb in excon-addressable-0.1.1
- old
+ new
@@ -1,8 +1,7 @@
# frozen_string_literal: true
-require 'addressable/uri'
-require 'addressable/template'
+require 'addressable'
require 'excon'
require 'excon/addressable/version'
Excon.defaults[:uri_parser] = Addressable::URI
@@ -10,11 +9,11 @@
module Excon
# Addressable addition to Excon.
#
module Addressable
def new(url, params = {})
- if (variables = params.delete(:expand))
- url = ::Addressable::Template.new(url).expand(variables)
+ if (template = ::Addressable::Template.new(url)) && template.variables.any?
+ url = template.expand(params.delete(:expand).to_h)
end
super
end
end