lib/bitly/utils.rb in philnash-bitly-0.1.2 vs lib/bitly/utils.rb in philnash-bitly-0.1.4
- old
+ new
@@ -1,5 +1,7 @@
+require 'cgi'
+
module Bitly
module Utils
private
def underscore(camel_cased_word) # stolen from rails
camel_cased_word.to_s.gsub(/::/, '/').
@@ -29,11 +31,11 @@
def create_url(resource="",args={})
args = args.merge({:login => @login, :apiKey => @api_key, :version => API_VERSION})
url = URI.join(API_URL,resource)
long_urls = args.delete(:long_urls)
- url.query = args.map { |k,v| "%s=%s" % [URI.encode(k.to_s), URI.encode(v.to_s)] }.join("&")
- url.query << "&" + long_urls.map { |long_url| "longUrl=#{URI.encode(long_url)}" }.join("&") unless long_urls.nil?
+ url.query = args.map { |k,v| "%s=%s" % [CGI.escape(k.to_s), CGI.escape(v.to_s)] }.join("&")
+ url.query << "&" + long_urls.map { |long_url| "longUrl=#{CGI.escape(long_url)}" }.join("&") unless long_urls.nil?
url
end
def get_result(request)
result = JSON.parse(Net::HTTP.get(request))
\ No newline at end of file