Skip to content

Commit

Permalink
fix: file extension handling in GetCategory function
Browse files Browse the repository at this point in the history
  • Loading branch information
divyam234 committed Apr 19, 2024
1 parent 3ca28cc commit a773482
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion internal/category/category.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ var (
)

func GetCategory(fileName string) Category {
fileExtension := strings.Split(strings.ToLower(filepath.Ext(fileName)), ".")[1]
fileExtension := filepath.Ext(fileName)
if fileExtension != "" {
fileExtension = strings.ToLower(fileExtension[1:])

}

if contains(documentExtensions, fileExtension) {
return Document
Expand Down
2 changes: 1 addition & 1 deletion pkg/services/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"strings"

"github.com/divyam234/teldrive/internal/cache"
category "github.com/divyam234/teldrive/internal/category"
"github.com/divyam234/teldrive/internal/category"
"github.com/divyam234/teldrive/internal/config"
"github.com/divyam234/teldrive/internal/database"
"github.com/divyam234/teldrive/internal/http_range"
Expand Down

0 comments on commit a773482

Please sign in to comment.