Skip to content

Commit

Permalink
Handle URI changes from 1.8.7, 1.9.3 and 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pixeltrix committed Feb 23, 2013
1 parent bc378ec commit 5ba0cfa
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/prowler/application.rb
Expand Up @@ -147,7 +147,7 @@ def send_notifications? #:nodoc:
end

def perform_get(command, params, klass) #:nodoc:
url = URI.parse("#{service_url}/#{command}?#{params.map{ |k,v| %(#{URI.encode(k.to_s)}=#{URI.encode(v.to_s)}) }.join('&')}")
url = parse_url("#{service_url}/#{command}?#{params.map{ |k,v| %(#{escape_url(k.to_s)}=#{escape_url(v.to_s)}) }.join('&')}")
request = Net::HTTP::Get.new("#{url.path}?#{url.query}", headers)
perform_request(url, request, klass)
end
Expand Down Expand Up @@ -206,5 +206,17 @@ def format_api_key(command, api_key) #:nodoc:
api_key.to_s
end
end

def url_parser
@url_parser ||= defined?(URI::Parser) ? URI::Parser.new : URI
end

def parse_url(url)
url_parser.parse(url)
end

def escape_url(url)
url_parser.escape(url)
end
end
end

0 comments on commit 5ba0cfa

Please sign in to comment.