class Addressable::URI

def inferred_port

Returns:
  • (Integer) - The inferred port component.
def inferred_port
  if self.port.to_i == 0
    if self.scheme
      URI.port_mapping[self.scheme.strip.downcase]
    else
      nil
    end
  else
    self.port.to_i
  end
end