Skip to content

Commit

Permalink
refactor(converters): Improve name detection
Browse files Browse the repository at this point in the history
Some workout files don't have a name; in that case, we use the filename
as the name of the workout.
  • Loading branch information
jovandeginste committed Jan 9, 2025
1 parent d6b62f2 commit 5c985a6
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pkg/converters/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@ func Parse(filename string, content []byte) (*gpx.GPX, error) {
return ParseGPX(content)
}

basename := path.Base(filename)

c, err := parseContent(basename, content)
if err != nil {
return nil, err
}

if c.Name == "" {
c.Name = basename
}

return c, nil
}

func parseContent(filename string, content []byte) (*gpx.GPX, error) {
suffix := path.Ext(filename)

switch suffix {
Expand Down

0 comments on commit 5c985a6

Please sign in to comment.