Skip to content

Commit e446610

Browse files
Handle null matches properly
1 parent f78b8fa commit e446610

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
@@ -40,7 +40,12 @@ object StdRegex {
4040
val captures = Array.newBuilder[Val.Str]
4141
val groupCount = matcher.groupCount()
4242
for (i <- 0 to groupCount) {
43-
captures += Val.Str(pos.noOffset, matcher.group(i))
43+
val m = matcher.group(i)
44+
if (m == null) {
45+
captures += Val.Null(pos.noOffset)
46+
} else {
47+
captures += Val.Str(pos.noOffset, m)
48+
}
4449
}
4550
val result = captures.result()
4651
Val.Obj.mk(pos.noOffset,

0 commit comments

Comments
 (0)