def append_query(base_uri, added_params = {})
      base_params = base_uri.query ? CGI.parse(base_uri.query) : {}
      get_params = base_params.merge(added_params.stringify_keys)
      base_uri.dup.tap do |uri|
        assignments = get_params.map do |k, v|
          case v
            when Array; v.map { |val| "#{::CGI.escape(k.to_s)}=#{::CGI.escape(val.to_s)}" }.join('&')
            else "#{::CGI.escape(k.to_s)}=#{::CGI.escape(v.to_s)}"
          end
        end
        uri.query = assignments.join('&')
      end
    end
def append_query(base_uri, added_params = {})
      base_params = base_uri.query ? CGI.parse(base_uri.query) : {}
      get_params = base_params.merge(added_params.stringify_keys)
      base_uri.dup.tap do |uri|
        assignments = get_params.map do |k, v|
          case v
            when Array; v.map { |val| "#{::CGI.escape(k.to_s)}=#{::CGI.escape(val.to_s)}" }.join('&')
            else "#{::CGI.escape(k.to_s)}=#{::CGI.escape(v.to_s)}"
          end
        end
        uri.query = assignments.join('&')
      end
    end
Appends GET parameters to a URI instance. Duplicate parameters will
 be replaced with the new value.
 @param [URI] base_uri The original URI to work with (will not be modified)
 @param [Hash] added_params To GET params to add.
 @return [URI] The URI with appended GET parameters