diff options
author | Martin Czygan <martin.czygan@gmail.com> | 2021-05-15 00:50:06 +0200 |
---|---|---|
committer | Martin Czygan <martin.czygan@gmail.com> | 2021-05-15 00:51:06 +0200 |
commit | 63ce90b56e4ef73075af034eec09e015b135caed (patch) | |
tree | 65304729381e8ac055f05280963b524f6030ad5f /skate | |
parent | 7fb9c24e4ee39d3a642a47ecbbb094c37394f57a (diff) | |
download | refcat-63ce90b56e4ef73075af034eec09e015b135caed.tar.gz refcat-63ce90b56e4ef73075af034eec09e015b135caed.zip |
fix subtle value extraction bug (https://i.imgur.com/tCvZzHo.png)
Diffstat (limited to 'skate')
-rw-r--r-- | skate/map.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/skate/map.go b/skate/map.go index c448848..698725a 100644 --- a/skate/map.go +++ b/skate/map.go @@ -130,7 +130,10 @@ func CreateFixedMapper(field string) Mapper { } f := func(p []byte) ([][]byte, error) { result := gjson.GetBytes(p, field) - key := []byte(result.String()) + // A subtle bug can emerge here: By default we use tab as separator. If + // the value extracted ends with the separator (e.g. tab), then we get + // an invalid row. Hence, trim all space. + key := []byte(strings.TrimSpace(result.String())) return [][]byte{key, p}, nil } return f |