PortInfo returns the port, protocol, and whether the AppSlugOrPort is a port or not.
()
| 96 | |
| 97 | // PortInfo returns the port, protocol, and whether the AppSlugOrPort is a port or not. |
| 98 | func (a ApplicationURL) PortInfo() (uint, string, bool) { |
| 99 | var ( |
| 100 | port uint64 |
| 101 | protocol string |
| 102 | isPort bool |
| 103 | err error |
| 104 | ) |
| 105 | |
| 106 | if strings.HasSuffix(a.AppSlugOrPort, "s") { |
| 107 | trimmed := strings.TrimSuffix(a.AppSlugOrPort, "s") |
| 108 | port, err = strconv.ParseUint(trimmed, 10, 16) |
| 109 | if err == nil { |
| 110 | protocol = "https" |
| 111 | isPort = true |
| 112 | } |
| 113 | } else { |
| 114 | port, err = strconv.ParseUint(a.AppSlugOrPort, 10, 16) |
| 115 | if err == nil { |
| 116 | protocol = "http" |
| 117 | isPort = true |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | return uint(port), protocol, isPort |
| 122 | } |
| 123 | |
| 124 | func (a *ApplicationURL) ChangePortProtocol(target string) ApplicationURL { |
| 125 | newAppURL := *a |
no outgoing calls
no test coverage detected