Move test for empty RTMP 'app' into parseURL().

This commit is contained in:
scruzin 2019-01-20 09:59:28 +10:30
parent a362d1d2ab
commit efe40a6778
2 changed files with 3 additions and 4 deletions

View File

@ -121,9 +121,6 @@ func Dial(url string, timeout uint, log Log) (*Conn, error) {
if err != nil {
return nil, err
}
if c.link.app == "" {
return nil, errInvalidURL
}
if c.link.port == 0 {
switch {
case (c.link.protocol & featureSSL) != 0:

View File

@ -41,7 +41,6 @@ import (
)
// parseURL parses an RTMP URL (ok, technically it is lexing).
//
func parseURL(addr string) (protocol int32, host string, port uint16, app, playpath string, err error) {
u, err := url.Parse(addr)
if err != nil {
@ -81,6 +80,9 @@ func parseURL(addr string) (protocol int32, host string, port uint16, app, playp
}
elems := strings.SplitN(u.Path[1:], "/", 3)
app = elems[0]
if app == "" {
return protocol, host, port, app, playpath, errInvalidURL
}
playpath = elems[1]
if len(elems) == 3 && len(elems[2]) != 0 {
playpath = path.Join(elems[1:]...)