File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -738,7 +738,7 @@ func (c *ServeCommand) BuildPushpinRoutes() []string {
738738 }
739739
740740 // Target:
741- target := u . Host
741+ target := normalizeHost ( u )
742742 // 1. `over_http`: Enable WebSocket-over-HTTP
743743 target += ",over_http"
744744 // 2. `ssl`: If backend is https
@@ -758,6 +758,26 @@ func (c *ServeCommand) BuildPushpinRoutes() []string {
758758 return routes
759759}
760760
761+ func normalizeHost (u * url.URL ) string {
762+ host := u .Host
763+
764+ // If Host already has a port, SplitHostPort succeeds
765+ // This an attempt at future-proofing as it handles IPv6
766+ if _ , _ , err := net .SplitHostPort (host ); err == nil {
767+ return host
768+ }
769+
770+ switch u .Scheme {
771+ case "https" :
772+ return net .JoinHostPort (host , "443" )
773+ case "http" :
774+ return net .JoinHostPort (host , "80" )
775+ default :
776+ // Unknown scheme, leave untouched
777+ return host
778+ }
779+ }
780+
761781func formatPushpinLog (line string ) (string , string ) {
762782 level := "INFO"
763783 msg := line
You can’t perform that action at this time.
0 commit comments