Skip to content

Commit 3212a52

Browse files
Handle null matches properly
1 parent e446610 commit 3212a52

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

sjsonnet/src/sjsonnet/StdRegex.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ object StdRegex {
1717
returnStr = Val.Str(pos.noOffset, matcher.group(0))
1818
}
1919
for (i <- 1 to groupCount) {
20-
captures += Val.Str(pos.noOffset, matcher.group(i))
20+
val m = matcher.group(i)
21+
if (m == null) {
22+
captures += Val.Null(pos.noOffset)
23+
} else {
24+
captures += Val.Str(pos.noOffset, m)
25+
}
2126
}
2227
}
2328
val result = captures.result()

0 commit comments

Comments
 (0)