Skip to content

Commit

Permalink
fix generating media URL with leading slash in control attribute (blu…
Browse files Browse the repository at this point in the history
  • Loading branch information
jwetzell authored Sep 26, 2024
1 parent 6ed93de commit 9a9e982
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/description/media.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func (m Media) URL(contentBase *base.URL) (*base.URL, error) {
// if there's a query, insert it after the query
// otherwise insert it after the path
strURL := contentBase.String()
if m.Control[0] != '?' && !strings.HasSuffix(strURL, "/") {
if m.Control[0] != '?' && m.Control[0] != '/' && !strings.HasSuffix(strURL, "/") {
strURL += "/"
}

Expand Down
10 changes: 10 additions & 0 deletions pkg/description/media_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ func TestMediaURL(t *testing.T) {
mustParseURL("rtsps://myuser:mypass@192.168.1.99:554/"),
mustParseURL("rtsps://myuser:mypass@192.168.1.99:554/path/trackID=7"),
},
{
"absolute control, base url no trailing slash",
[]byte("v=0\r\n" +
"s= \r\n" +
"m=video 0 RTP/AVP 96\r\n" +
"a=rtpmap:96 H264/90000\r\n" +
"a=control:/test"),
mustParseURL("rtsp://myuser:mypass@192.168.1.99:554"),
mustParseURL("rtsp://myuser:mypass@192.168.1.99:554/test"),
},
{
"relative control",
[]byte("v=0\r\n" +
Expand Down

0 comments on commit 9a9e982

Please sign in to comment.