encoding: check whether encoding.Name() is empty before calling strings.ToLower (#2707)

This commit is contained in:
ktr
2019-03-23 05:34:43 +09:00
committed by Doug Fawley
parent aded19ed6f
commit 0e83fbebe8

View File

@ -102,10 +102,10 @@ func RegisterCodec(codec Codec) {
if codec == nil {
panic("cannot register a nil Codec")
}
contentSubtype := strings.ToLower(codec.Name())
if contentSubtype == "" {
panic("cannot register Codec with empty string result for String()")
if codec.Name() == "" {
panic("cannot register Codec with empty string result for Name()")
}
contentSubtype := strings.ToLower(codec.Name())
registeredCodecs[contentSubtype] = codec
}