Module: DomainExtractor::QueryParams

Defined in:
lib/domain_extractor/query_params.rb

Overview

QueryParams transforms URL query strings into Ruby hashes.

Constant Summary collapse

EMPTY =
{}.freeze

Class Method Summary collapse

Class Method Details

.call(raw_query) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/domain_extractor/query_params.rb', line 12

def call(raw_query)
  return EMPTY if raw_query.nil? || raw_query.empty?

  ::URI.decode_www_form(raw_query, Encoding::UTF_8).each_with_object({}) do |(key, value), params|
    next if key.nil? || key.empty?

    params[key] = normalize_value(value)
  end
rescue ArgumentError
  EMPTY
end