class Addressable::URI

def normalized_userinfo

Returns:
  • (String) - The userinfo component, normalized.
def normalized_userinfo
  return nil unless self.userinfo
  return @normalized_userinfo if defined?(@normalized_userinfo)
  @normalized_userinfo ||= begin
    current_user = self.normalized_user
    current_password = self.normalized_password
    if !current_user && !current_password
      nil
    elsif current_user && current_password
      "#{current_user}:#{current_password}".dup
    elsif current_user && !current_password
      "#{current_user}".dup
    end
  end
  # All normalized values should be UTF-8
  if @normalized_userinfo
    @normalized_userinfo.force_encoding(Encoding::UTF_8)
  end
  @normalized_userinfo
end