I think this is unrelated to implementations of foreman_url, it's about the setting and data itself, which this PR is intended to address.  We can take the time to fix stuff properly now too :)

I don't think treating 80/443 as special is enough, since it leaves the foreman_url setting in a weird state where it's not clear what function it's used for, or which bits of the URL are important in each circumstance.  We haven't solved the problem in the issue description, which is obeying the port in the foreman_url setting in any HTTP+HTTPS setup.