aboutsummaryrefslogtreecommitdiffstats
path: root/skate/map.go
diff options
context:
space:
mode:
authorMartin Czygan <martin.czygan@gmail.com>2021-05-15 00:50:06 +0200
committerMartin Czygan <martin.czygan@gmail.com>2021-05-15 00:51:06 +0200
commit63ce90b56e4ef73075af034eec09e015b135caed (patch)
tree65304729381e8ac055f05280963b524f6030ad5f /skate/map.go
parent7fb9c24e4ee39d3a642a47ecbbb094c37394f57a (diff)
downloadrefcat-63ce90b56e4ef73075af034eec09e015b135caed.tar.gz
refcat-63ce90b56e4ef73075af034eec09e015b135caed.zip
fix subtle value extraction bug (https://i.imgur.com/tCvZzHo.png)
Diffstat (limited to 'skate/map.go')
-rw-r--r--skate/map.go5
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