Skip to content

Commit 1e3accc

Browse files
committed
fix gramtentTypes
Signed-off-by: Kirill Danshin <[email protected]>
1 parent d82c914 commit 1e3accc

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ Some Good Utils
55

66

77
## License
8-
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fgramework%2Futils.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fgramework%2Futils?ref=badge_large)
8+
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fgramework%2Futils.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fgramework%2Futils?ref=badge_large)

gramtentTypes/contentTypeByExtension.go

+7-10
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ package grametentTypes
33
import (
44
"path/filepath"
55
"sync"
6-
7-
"github.com/kirillDanshin/myutils"
86
)
97

108
const (
@@ -128,6 +126,7 @@ var extToContentType = map[string]string{
128126
".funk": "audio/make",
129127
".g3": "image/g3fax",
130128
".g": "text/plain",
129+
".go": "text/plain",
131130
".gif": "image/gif",
132131
".gl": "video/gl",
133132
".gsd": "audio/x-gsm",
@@ -559,19 +558,17 @@ var ctLock = sync.RWMutex{}
559558
// RegisterContentType adds or replaces a contentType for given extension
560559
func RegisterContentType(ext, contentType string) {
561560
if ext != emptyString && ext[0] != dotByte {
562-
ext = myutils.Concat(dotString, ext)
561+
ext = dotString + ext
563562
}
564563
ctLock.Lock()
565564
extToContentType[ext] = contentType
566565
ctLock.Unlock()
567566
}
568567

569-
// TypeByExtension returns the Content-Type type associated with the file extension ext.
570-
func TypeByExtension(fullfilename string) (t string) {
568+
// TypeByExtension returns the Content-Type associated with the file extension.
569+
func TypeByExtension(fullFilename string) (t string) {
571570
ctLock.RLock()
572-
defer ctLock.RUnlock()
573-
if ct, ok := extToContentType[filepath.Ext(fullfilename)]; ok {
574-
return ct
575-
}
576-
return emptyString
571+
ct := extToContentType[filepath.Ext(fullFilename)]
572+
ctLock.RUnlock()
573+
return ct
577574
}

0 commit comments

Comments
 (0)