diff --git a/lib/ferrum/browser/process.rb b/lib/ferrum/browser/process.rb index 006f975a..2a754443 100644 --- a/lib/ferrum/browser/process.rb +++ b/lib/ferrum/browser/process.rb @@ -64,11 +64,9 @@ def initialize(options) if options.ws_url response = parse_json_version(options.ws_url) - self.ws_url = response&.[]("webSocketDebuggerUrl") || options.ws_url + self.ws_url = options.ws_url return - end - - if options.url + elsif options.url response = parse_json_version(options.url) self.ws_url = response&.[]("webSocketDebuggerUrl") return @@ -187,10 +185,11 @@ def close_io(*ios) end def parse_json_version(url) - url = URI.join(url, "/json/version") + uri = Addressable::URI.parse(url) + uri.path = "/json/version" - if %w[wss ws].include?(url.scheme) - url.scheme = case url.scheme + if %w[wss ws].include?(uri.scheme) + uri.scheme = case uri.scheme when "ws" "http" when "wss" @@ -198,7 +197,7 @@ def parse_json_version(url) end end - response = JSON.parse(::Net::HTTP.get(URI(url.to_s))) + response = JSON.parse(::Net::HTTP.get(URI(uri.to_s))) @v8_version = response["V8-Version"] @browser_version = response["Browser"]