From d9b819e85e9bb880baee462682bf72b6147f02c1 Mon Sep 17 00:00:00 2001 From: aler9 <46489434+aler9@users.noreply.github.com> Date: Tue, 19 Jan 2021 14:43:54 +0100 Subject: [PATCH] base: fix PathSplitQuery --- pkg/base/url.go | 3 ++- pkg/base/url_test.go | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/base/url.go b/pkg/base/url.go index f7aa5f3f..d42a5580 100644 --- a/pkg/base/url.go +++ b/pkg/base/url.go @@ -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:] } diff --git a/pkg/base/url_test.go b/pkg/base/url_test.go index 99bdf2c7..11c8e977 100644 --- a/pkg/base/url_test.go +++ b/pkg/base/url_test.go @@ -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)