mirror of https://github.com/gofiber/fiber.git
parent
36796ee7a1
commit
658b4e42b1
|
@ -37,8 +37,10 @@ func ParseVendorSpecificContentType(cType string) string {
|
|||
var parsableType string
|
||||
if semiColonIndex := strings.Index(cType, ";"); semiColonIndex == -1 {
|
||||
parsableType = cType[plusIndex+1:]
|
||||
} else {
|
||||
} else if plusIndex < semiColonIndex {
|
||||
parsableType = cType[plusIndex+1 : semiColonIndex]
|
||||
} else {
|
||||
return cType[:semiColonIndex]
|
||||
}
|
||||
|
||||
slashIndex := strings.Index(cType, "/")
|
||||
|
|
|
@ -59,6 +59,12 @@ func Test_ParseVendorSpecificContentType(t *testing.T) {
|
|||
cType := ParseVendorSpecificContentType("application/json")
|
||||
AssertEqual(t, "application/json", cType)
|
||||
|
||||
cType = ParseVendorSpecificContentType("multipart/form-data; boundary=dart-http-boundary-ZnVy.ICWq+7HOdsHqWxCFa8g3D.KAhy+Y0sYJ_lBADypu8po3_X")
|
||||
AssertEqual(t, "multipart/form-data", cType)
|
||||
|
||||
cType = ParseVendorSpecificContentType("multipart/form-data")
|
||||
AssertEqual(t, "multipart/form-data", cType)
|
||||
|
||||
cType = ParseVendorSpecificContentType("application/vnd.api+json; version=1")
|
||||
AssertEqual(t, "application/json", cType)
|
||||
|
||||
|
|
Loading…
Reference in New Issue