Skip to content

Commit 398e09f

Browse files
committed
detect json by mediaType
1 parent 31fdf2b commit 398e09f

File tree

1 file changed

+2
-2
lines changed
  • pluto-plugins/plugins/network/core/lib/src/main/java/com/pluto/plugins/network/intercept

1 file changed

+2
-2
lines changed

pluto-plugins/plugins/network/core/lib/src/main/java/com/pluto/plugins/network/intercept/NetworkData.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class NetworkData {
2525
private fun parseGraphqlData(): GraphqlData? {
2626
if (method != "POST" ||
2727
body == null ||
28-
!body.isLikelyJson
28+
!body.isJson
2929
) return null
3030
val json = runCatching { JSONObject(body!!.body.toString()) }.getOrNull() ?: return null
3131
val query = json.optString("query") ?: return null
@@ -69,7 +69,7 @@ class NetworkData {
6969
internal val isBinary: Boolean = BINARY_MEDIA_TYPES.contains(mediaType)
7070
val sizeInBytes: Long = body.length.toLong()
7171
internal val mediaTypeFull: String = "$mediaType/$mediaSubtype"
72-
val isLikelyJson get() = !isBinary && body.startsWith('{')
72+
val isJson get() = mediaTypeFull == "application/json"
7373
}
7474

7575
companion object {

0 commit comments

Comments
 (0)