// ParseAddress takes an address and tries to extract the protocol from it.
// Protocols may be prepended by the "protocol://" notation.
// If no protocol is given, defaultProtocol is returned.
// The first parameter returned is the address, the second denotes the protocol.
// The protocol is allways returned as lowercase string. If only a number is
// given as an address the number is assumed to be a port. As of this "80" and
// ":80" will return ":80" as the address.
ParseAddress takes an address and tries to extract the protocol from it.
Protocols may be prepended by the "protocol://" notation.
If no protocol is given, defaultProtocol is returned.
The first parameter returned is the address, the second denotes the protocol.
The protocol is allways returned as lowercase string. If only a number is
given as an address the number is assumed to be a port. As of this "80" and
":80" will return ":80" as the address.
// ParseAddress takes an address and tries to extract the protocol from it . // Protocols may be prepended by the " protocol : // " notation . // If no protocol is given defaultProtocol is returned . // The first parameter returned is the address the second denotes the protocol . // The protocol is allways returned as lowercase string . If only a number is // given as an address the number is assumed to be a port . As of this " 80 " and // " : 80 " will return " : 80 " as the address .
func ParseAddress(addressString string, defaultProtocol string) (protocol, address string) {
	protocolIdx := strings.Index(addressString, "://")
	if protocolIdx == -1 {
		protocol = strings.ToLower(defaultProtocol)
		address = addressString
	} else {
		protocol = strings.ToLower(addressString[:protocolIdx])
		address = addressString[protocolIdx+3:]
	}
	if tstrings.IsInt(address) {
		address = ":" + address
	}
	return
}
func ParseAddress ( addressString string , defaultProtocol string ) ( protocol , address string ) { protocolIdx := strings . Index ( addressString , " " ) if protocolIdx == - 1 { protocol = strings . ToLower ( defaultProtocol ) address = addressString } else { protocol = strings . ToLower ( addressString [ : protocolIdx ] ) address = addressString [ protocolIdx + 3 : ] } if tstrings . IsInt ( address ) { address = " " + address } return }
ParseAddress takes an address and tries to extract the protocol from it.
ParseAddress takes an address and tries to extract the protocol from it .
// Allow sole numbers as a synonym for ":port"