fix: curl parser json detection issues (#2370)
Co-authored-by: Andrew Bastin <andrewbastin.k@gmail.com>
This commit is contained in:
@@ -158,14 +158,11 @@ const getXMLBody = (rawData: string) =>
|
|||||||
O.alt(() => O.some(rawData))
|
O.alt(() => O.some(rawData))
|
||||||
)
|
)
|
||||||
|
|
||||||
const getFormattedJSON = (jsonString: string) =>
|
const getFormattedJSON = flow(
|
||||||
pipe(
|
safeParseJSON,
|
||||||
jsonString.replaceAll('\\"', '"'),
|
O.map((parsedJSON) => JSON.stringify(parsedJSON, null, 2)),
|
||||||
safeParseJSON,
|
O.getOrElse(() => "{ }")
|
||||||
O.map((parsedJSON) => JSON.stringify(parsedJSON, null, 2)),
|
)
|
||||||
O.getOrElse(() => "{ }"),
|
|
||||||
O.of
|
|
||||||
)
|
|
||||||
|
|
||||||
const getXWWWFormUrlEncodedBody = flow(
|
const getXWWWFormUrlEncodedBody = flow(
|
||||||
decodeURIComponent,
|
decodeURIComponent,
|
||||||
@@ -191,7 +188,7 @@ export function parseBody(
|
|||||||
case "application/ld+json":
|
case "application/ld+json":
|
||||||
case "application/vnd.api+json":
|
case "application/vnd.api+json":
|
||||||
case "application/json":
|
case "application/json":
|
||||||
return getFormattedJSON(rawData)
|
return O.some(getFormattedJSON(rawData))
|
||||||
|
|
||||||
case "application/x-www-form-urlencoded":
|
case "application/x-www-form-urlencoded":
|
||||||
return getXWWWFormUrlEncodedBody(rawData)
|
return getXWWWFormUrlEncodedBody(rawData)
|
||||||
|
|||||||
Reference in New Issue
Block a user