module ActionDispatch::Http::URL

def normalize_port(port, protocol)

def normalize_port(port, protocol)
  return unless port
  case protocol
  when "//" then yield port
  when "https://"
    yield port unless port.to_i == 443
  else
    yield port unless port.to_i == 80
  end
end