I changed the resolver to first replace the grok patterns %{subPattern:fieldName} by the corresponding oniguruma named capture groups (?<fieldName>...) and then in a second pass create the fields array for all named capture groups taking the corresponding group nesting into account. Since there could be several unnamed capture groups as well, the fields array now contains null values for them. During the actual pattern parsing process these null fields are ignored.
I also added a bunch of additional unit tests in order to ensure the proper parsing of them.
bug fix for: https://github.com/Beh01der/node-grok/issues/1
I changed the resolver to first replace the
grok
patterns%{subPattern:fieldName}
by the correspondingoniguruma
named capture groups(?<fieldName>...)
and then in a second pass create thefields
array for all named capture groups taking the corresponding group nesting into account. Since there could be several unnamed capture groups as well, thefields
array now containsnull
values for them. During the actual pattern parsing process thesenull
fields are ignored.I also added a bunch of additional unit tests in order to ensure the proper parsing of them.