Allow RTMP token as stream key in the path

This commit is contained in:
Ingo Oppermann
2023-01-13 11:12:21 +01:00
parent ea79b87236
commit f0ff3b89c1
2 changed files with 99 additions and 34 deletions

26
rtmp/rtmp_test.go Normal file
View File

@@ -0,0 +1,26 @@
package rtmp
import (
"net/url"
"testing"
"github.com/stretchr/testify/require"
)
func TestToken(t *testing.T) {
data := [][]string{
{"/foo/bar", "/foo", "bar"},
{"/foo/bar?token=abc", "/foo/bar", "abc"},
{"/foo/bar/abc", "/foo/bar", "abc"},
}
for _, d := range data {
u, err := url.Parse(d[0])
require.NoError(t, err)
path, token := getToken(u)
require.Equal(t, d[1], path, "url=%s", u.String())
require.Equal(t, d[2], token, "url=%s", u.String())
}
}