mirror of
https://github.com/lostisland/faraday.git
synced 2025-11-12 00:04:04 -05:00
make the default uri parser configurable
This commit is contained in:
parent
63b8a1d977
commit
c24a02c73b
@ -187,8 +187,11 @@ module Faraday
|
|||||||
|
|
||||||
class << self
|
class << self
|
||||||
attr_writer :default_params_encoder
|
attr_writer :default_params_encoder
|
||||||
|
attr_accessor :default_uri_parser
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self.default_uri_parser = Kernel.method(:URI)
|
||||||
|
|
||||||
# Stolen from Rack
|
# Stolen from Rack
|
||||||
def normalize_params(params, name, v = nil)
|
def normalize_params(params, name, v = nil)
|
||||||
name =~ %r(\A[\[\]]*([^\[\]]+)\]*)
|
name =~ %r(\A[\[\]]*([^\[\]]+)\]*)
|
||||||
@ -235,7 +238,7 @@ module Faraday
|
|||||||
if url.respond_to?(:host)
|
if url.respond_to?(:host)
|
||||||
url
|
url
|
||||||
elsif url.respond_to?(:to_str)
|
elsif url.respond_to?(:to_str)
|
||||||
Kernel.URI(url)
|
default_uri_parser.call(url)
|
||||||
else
|
else
|
||||||
raise ArgumentError, "bad argument (expected URI object or URI string)"
|
raise ArgumentError, "bad argument (expected URI object or URI string)"
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user