base: fix PathSplitQuery

This commit is contained in:
aler9
2021-01-19 14:43:54 +01:00
parent 039d69ba42
commit d9b819e85e
2 changed files with 6 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"net/url"
"strconv"
"strings"
)
func stringsReverseIndex(s, substr string) int {
@@ -35,7 +36,7 @@ func PathSplitControlAttribute(pathAndQuery string) (int, string, bool) {
// PathSplitQuery splits a path from a query.
func PathSplitQuery(pathAndQuery string) (string, string) {
i := stringsReverseIndex(pathAndQuery, "?")
i := strings.Index(pathAndQuery, "?")
if i >= 0 {
return pathAndQuery[:i], pathAndQuery[i:]
}

View File

@@ -31,6 +31,10 @@ func TestURLRTSPPath(t *testing.T) {
MustParseURL("rtsp://192.168.1.99:554/user=tmp&password=BagRep1!&channel=1&stream=0.sdp"),
"user=tmp&password=BagRep1!&channel=1&stream=0.sdp",
},
{
MustParseURL("rtsp://localhost:8554/teststream?query1?query2"),
"teststream",
},
} {
b, ok := ca.u.RTSPPath()
require.Equal(t, true, ok)