Sha256: 04e6791d24fb48cdf07c59818a7fb648504cb6705cf3d49986ee50c9d1ff2fc2

Contents?: true

Size: 661 Bytes

Versions: 5

Compression:

Stored size: 661 Bytes

Contents

module RestCore; end
module RestCore::ParseQuery
  module_function
  begin
    require 'rack/utils'
    def parse_query(qs, d = nil)
      Rack::Utils.parse_query(qs, d)
    end
  rescue LoadError
    # Stolen from Rack
    def parse_query(qs, d = nil)
      params = {}

      (qs || '').split(d ? /[#{d}] */un : /[&;] */un).each do |p|
        k, v = p.split('=', 2).map { |x| URI.decode_www_form_component(x) }
        if cur = params[k]
          if cur.class == Array
            params[k] << v
          else
            params[k] = [cur, v]
          end
        else
          params[k] = v
        end
      end

      return params
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rest-core-3.4.1 lib/rest-core/util/parse_query.rb
rest-core-3.4.0 lib/rest-core/util/parse_query.rb
rest-core-3.3.3 lib/rest-core/util/parse_query.rb
rest-core-3.3.2 lib/rest-core/util/parse_query.rb
rest-core-3.3.1 lib/rest-core/util/parse_query.rb