Skip to content

Commit

Permalink
Handle null matches properly
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenamar-db committed Dec 20, 2024
1 parent e446610 commit 3212a52
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sjsonnet/src/sjsonnet/StdRegex.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ object StdRegex {
returnStr = Val.Str(pos.noOffset, matcher.group(0))
}
for (i <- 1 to groupCount) {
captures += Val.Str(pos.noOffset, matcher.group(i))
val m = matcher.group(i)
if (m == null) {
captures += Val.Null(pos.noOffset)
} else {
captures += Val.Str(pos.noOffset, m)
}
}
}
val result = captures.result()
Expand Down

0 comments on commit 3212a52

Please sign in to comment.