Skip to content

Commit

Permalink
Fix json (#6)
Browse files Browse the repository at this point in the history
* fix json handling
* fix linter
  • Loading branch information
efectn authored Jan 28, 2024
1 parent f509ed3 commit 44538f8
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions map.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 44538f8

Please sign in to comment.