After some different thoughts I think I have the solution... We can just use the repo.html_url as returned by Github as this will always be a valid URL which contains the exact info we need.

On the berks side (the client side) we can still use URI.parse to decompose the url, because Github Enterprise does not support IPv6. So the repo.html_url returned by Github, will never be an IPv6 address and so we will never hit the IPv6 corner case you mentioned.

I will update the PR to reflect this change...