lib/infrataster/resources/http_resource.rb in infrataster-0.1.11 vs lib/infrataster/resources/http_resource.rb in infrataster-0.1.12
- old
+ new
@@ -9,11 +9,15 @@
attr_reader :uri, :options
def initialize(url_str, options = {})
@options = {params: {}, method: :get, headers: {}}.merge(options)
@uri = URI.parse(url_str)
- unless %w!http https!.include?(@uri.scheme)
- raise Error, "The provided url, '#{@uri}', is not http or https."
+ if @uri.scheme
+ unless %w!http https!.include?(@uri.scheme)
+ raise Error, "The provided url, '#{@uri}', is not http or https."
+ end
+ else
+ @uri = URI::HTTP.build([@uri.userinfo, @uri.host, @uri.port, @uri.path, @uri.query, @uri.fragment])
end
end
def to_s
"http '#{@uri}' with #{@options}"