Skip to content

Commit

Permalink
better XML / JSON detection from Content-Type header
Browse files Browse the repository at this point in the history
  • Loading branch information
darklynx committed Nov 3, 2017
1 parent cb58809 commit efad13b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions web/basket.html
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@
contentType = (contentType || []).join(",");
if ("application/x-www-form-urlencoded" === contentType.toLowerCase()) {
return "FORM";
} else if (/^application\/(json|.+\+json).*/i.test(contentType)) {
} else if (/^(application|text)\/(json|.+\+json).*/i.test(contentType)) {
return "JSON";
} else if (/^application\/(xml|.+\+xml).*/i.test(contentType)) {
} else if (/^(application|text)\/(xml|.+\+xml).*/i.test(contentType)) {
return "XML";
} else {
return "UNKNOWN";
Expand Down
4 changes: 2 additions & 2 deletions web_basket.html.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ const (
contentType = (contentType || []).join(",");
if ("application/x-www-form-urlencoded" === contentType.toLowerCase()) {
return "FORM";
} else if (/^application\/(json|.+\+json).*/i.test(contentType)) {
} else if (/^(application|text)\/(json|.+\+json).*/i.test(contentType)) {
return "JSON";
} else if (/^application\/(xml|.+\+xml).*/i.test(contentType)) {
} else if (/^(application|text)\/(xml|.+\+xml).*/i.test(contentType)) {
return "XML";
} else {
return "UNKNOWN";
Expand Down

0 comments on commit efad13b

Please sign in to comment.