fix support for regexp groups greater than 10 (#6033)

This commit is contained in:
Alessandro Ros
2026-08-04 18:50:38 +00:00
committed by GitHub
parent d8b2e4b6fc
commit 543dbc9eb8
2 changed files with 9 additions and 4 deletions
+2 -4
View File
@@ -32,10 +32,8 @@ func emptyTimer() *time.Timer {
}
func resolveSource(s string, matches []string, query string) string {
if len(matches) > 1 {
for i, ma := range matches[1:] {
s = strings.ReplaceAll(s, "$G"+strconv.FormatInt(int64(i+1), 10), ma)
}
for i := len(matches) - 1; i >= 1; i-- {
s = strings.ReplaceAll(s, "$G"+strconv.FormatInt(int64(i), 10), matches[i])
}
s = strings.ReplaceAll(s, "$MTX_QUERY", query)
+7
View File
@@ -105,6 +105,13 @@ func TestResolveSource(t *testing.T) {
query: "",
expected: "udp+rtp://192.168.1.100:5000",
},
{
name: "multi digit group substitution",
source: "rtsp://example.com/$G10",
matches: []string{"full", "g1", "g2", "g3", "g4", "g5", "g6", "g7", "g8", "g9", "g10"},
query: "",
expected: "rtsp://example.com/g10",
},
} {
t.Run(ca.name, func(t *testing.T) {
result := resolveSource(ca.source, ca.matches, ca.query)