class Addressable::URI

def normalized_password

Returns:
  • (String) - The password component, normalized.
def normalized_password
  self.password && @normalized_password ||= (begin
    if self.normalized_scheme =~ /https?/ && self.password.strip.empty? &&
        (!self.user || self.user.strip.empty?)
      nil
    else
      Addressable::URI.normalize_component(
        self.password.strip,
        Addressable::URI::CharacterClasses::UNRESERVED
      )
    end
  end)
end