fix support for regexp groups greater than 10 (#6033)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user