Skip to content

Commit 20b70d0

Browse files
committed
feat: support unique when format result, #104
1 parent 0a833b0 commit 20b70d0

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

core/format.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func Format(opts Option) {
2525
if err != nil {
2626
return
2727
}
28-
group := make(map[string][]*baseline.Baseline)
28+
group := make(map[string]map[string]*baseline.Baseline)
2929
for _, line := range bytes.Split(bytes.TrimSpace(content), []byte("\n")) {
3030
var result baseline.Baseline
3131
err := json.Unmarshal(line, &result)
@@ -37,7 +37,10 @@ func Format(opts Option) {
3737
if err != nil {
3838
continue
3939
}
40-
group[result.Url.Host] = append(group[result.Url.Host], &result)
40+
if _, exists := group[result.Url.Host]; !exists {
41+
group[result.Url.Host] = make(map[string]*baseline.Baseline)
42+
}
43+
group[result.Url.Host][result.Path] = &result
4144
}
4245

4346
for _, results := range group {

0 commit comments

Comments
 (0)