Skip to content

Commit b60408c

Browse files
authored
🐛 bug: Fix MIME type equality checks (#3603)
1 parent 845f95f commit b60408c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ctx.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ func (c *Ctx) BodyParser(out interface{}) error {
394394
if strings.HasSuffix(ctype, "json") {
395395
return c.app.config.JSONDecoder(c.Body(), out)
396396
}
397-
if strings.HasPrefix(ctype, MIMEApplicationForm) {
397+
if ctype == MIMEApplicationForm {
398398
data := make(map[string][]string)
399399
var err error
400400

@@ -415,7 +415,7 @@ func (c *Ctx) BodyParser(out interface{}) error {
415415

416416
return c.parseToStruct(bodyTag, out, data)
417417
}
418-
if strings.HasPrefix(ctype, MIMEMultipartForm) {
418+
if ctype == MIMEMultipartForm {
419419
multipartForm, err := c.fasthttp.MultipartForm()
420420
if err != nil {
421421
return err
@@ -431,7 +431,7 @@ func (c *Ctx) BodyParser(out interface{}) error {
431431

432432
return c.parseToStruct(bodyTag, out, data)
433433
}
434-
if strings.HasPrefix(ctype, MIMETextXML) || strings.HasPrefix(ctype, MIMEApplicationXML) {
434+
if ctype == MIMETextXML || ctype == MIMEApplicationXML {
435435
if err := xml.Unmarshal(c.Body(), out); err != nil {
436436
return fmt.Errorf("failed to unmarshal: %w", err)
437437
}

0 commit comments

Comments
 (0)