More elegant switch in parseURL() for port logic.

This commit is contained in:
scruzin 2019-01-21 10:57:40 +10:30
parent 3a70dc6ddc
commit 2697dcf515
1 changed files with 9 additions and 10 deletions

View File

@ -99,16 +99,15 @@ func parseURL(addr string) (protocol int32, host string, port uint16, app, playp
}
}
if port == 0 {
switch {
case (protocol & featureSSL) != 0:
port = 433
return errUnimplemented
case (protocol & featureHTTP) != 0:
port = 80
default:
port = 1935
}
switch {
case port != 0:
case (protocol & featureSSL) != 0:
return protocol, host, port, app, playpath, errUnimplemented // port = 433
case (protocol & featureHTTP) != 0:
port = 80
default:
port = 1935
}
return protocol, host, port, app, playpath, nil
}