I think you're probably right, but given the work in https://github.com/GregSutcliffe/foreman/tree/refactor_renderer2 is about unifying the two implementations of foreman_url (among other things) we might need to take some time to design that properly...

For now, I suggest something like:

    port = nil if [80,443].include?(port)

That will unset the port when it's on something standard, leading to `http://example.com` even when `foreman_url = https://example.com`. How does that sound?