class Addressable::URI

def normalized_user

Returns:
  • (String) - The user component, normalized.
def normalized_user
  return nil unless self.user
  return @normalized_user if defined?(@normalized_user)
  @normalized_user ||= begin
    if normalized_scheme =~ /https?/ && self.user.strip.empty? &&
        (!self.password || self.password.strip.empty?)
      nil
    else
      Addressable::URI.normalize_component(
        self.user.strip,
        Addressable::URI::CharacterClasses::UNRESERVED
      )
    end
  end
  # All normalized values should be UTF-8
  @normalized_user.force_encoding(Encoding::UTF_8) if @normalized_user
  @normalized_user
end