From 44538f821201ac396a247d9d4d1a91d414e8c382 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Efe=20=C3=87etin?= Date: Sun, 28 Jan 2024 23:32:40 +0300 Subject: [PATCH] Fix json (#6) * fix json handling * fix linter --- map.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/map.go b/map.go index 6dccd1e..4064018 100644 --- a/map.go +++ b/map.go @@ -13,6 +13,7 @@ import ( "golang.org/x/text/language" ) +// ErrUnsupportedFormat is returned when an unsupported map format is used. var ErrUnsupportedFormat = errors.New("unsupported map format") // loadMapFile loads a file as a map @@ -120,16 +121,18 @@ func loadMapJSON(f io.Reader) (map[string]string, error) { sb.WriteString(".") - if file.Extension == "img.xz.sha" { + if strings.HasSuffix(file.Extension, ".sha") { sb.WriteString("sha") - } else if file.Extension == "img.xz.asc" { + } else if strings.HasSuffix(file.Extension, ".asc") { sb.WriteString("asc") + } else if strings.HasSuffix(file.Extension, ".torrent") { + sb.WriteString("torrent") } else { sb.WriteString(file.Extension) } - builtUri := sb.String() - m[builtUri] = file.FileURL + builtURI := sb.String() + m[builtURI] = file.FileURL } return m, nil