fix #18: support upper case extension
This commit is contained in:
@ -1,5 +1,10 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type NewDecoderFunc func([]byte) Decoder
|
||||
|
||||
var decoderRegistry = make(map[string][]NewDecoderFunc)
|
||||
@ -7,6 +12,7 @@ var decoderRegistry = make(map[string][]NewDecoderFunc)
|
||||
func RegisterDecoder(ext string, dispatchFunc NewDecoderFunc) {
|
||||
decoderRegistry[ext] = append(decoderRegistry[ext], dispatchFunc)
|
||||
}
|
||||
func GetDecoder(ext string) []NewDecoderFunc {
|
||||
func GetDecoder(filename string) []NewDecoderFunc {
|
||||
ext := strings.ToLower(strings.TrimLeft(filepath.Ext(filename), "."))
|
||||
return decoderRegistry[ext]
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
package common
|
||||
|
||||
import "errors"
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type RawDecoder struct {
|
||||
file []byte
|
||||
@ -14,7 +17,7 @@ func NewRawDecoder(file []byte) Decoder {
|
||||
func (d *RawDecoder) Validate() error {
|
||||
for ext, sniffer := range snifferRegistry {
|
||||
if sniffer(d.file) {
|
||||
d.audioExt = ext
|
||||
d.audioExt = strings.ToLower(ext)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user