File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -34,9 +34,12 @@ impl Parse {
34
34
None => Ok ( None ) ,
35
35
Some ( capture) => {
36
36
let mut values: Vec < data:: Value > = Vec :: with_capacity ( self . fields . len ( ) ) ;
37
- for i in 0 .. self . fields . len ( ) {
37
+ for item in capture . iter ( ) . skip ( 1 ) {
38
38
// the first capture is the entire string
39
- values. push ( data:: Value :: from_string ( & capture[ i + 1 ] ) ) ;
39
+ match item {
40
+ None => values. push ( data:: Value :: None ) ,
41
+ Some ( match_) => values. push ( data:: Value :: from_string ( match_. as_str ( ) ) ) ,
42
+ } ;
40
43
}
41
44
Ok ( Some ( values) )
42
45
}
Original file line number Diff line number Diff line change
1
+ query = """ * |parse regex "(?P<url>.+)(?P<query>\\ ?.+)?""""
2
+ input = """ /track/?verbose=1&ip=1&_=1716389413340"""
3
+ output = """
4
+ [query=None] [url=/track/?verbose=1&ip=1&_=1716389413340]
5
+ """
6
+ error = """
7
+ """
You can’t perform that action at this time.
0 commit comments