class Addressable::Template

def normalize_value(value)

Returns:
  • (Hash, Array, String) - The normalized values

Parameters:
  • value (Hash, Array, String) --
def normalize_value(value)
  unless value.is_a?(Hash)
    value = value.respond_to?(:to_ary) ? value.to_ary : value.to_str
  end
  # Handle unicode normalization
  if value.kind_of?(Array)
    value.map! { |val| Addressable::IDNA.unicode_normalize_kc(val) }
  elsif value.kind_of?(Hash)
    value = value.inject({}) { |acc, (k, v)|
      acc[Addressable::IDNA.unicode_normalize_kc(k)] =
        Addressable::IDNA.unicode_normalize_kc(v)
      acc
    }
  else
    value = Addressable::IDNA.unicode_normalize_kc(value)
  end
  value
end