Fixes npe when given filename ending with "." #1994

This commit is contained in:
Mike Farah
2024-03-30 14:00:57 +11:00
parent 101cf14b8c
commit 28c406706a
2 changed files with 57 additions and 3 deletions
+5 -3
View File
@@ -123,9 +123,11 @@ func FormatStringFromFilename(filename string) string {
}
func FormatFromString(format string) (*Format, error) {
for _, printerFormat := range Formats {
if printerFormat.MatchesName(format) {
return printerFormat, nil
if format != "" {
for _, printerFormat := range Formats {
if printerFormat.MatchesName(format) {
return printerFormat, nil
}
}
}
return nil, fmt.Errorf("unknown format '%v' please use [%v]", format, GetAvailableOutputFormatString())