From 13dc310c5d76f363e28c8c0aa44f1824c4d7e571 Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Sat, 19 Jun 2021 17:49:55 -0400 Subject: [PATCH] fix some string handling --- .../webservices/GraphQLRepository.kt | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/webservices/GraphQLRepository.kt b/app/src/main/java/awais/instagrabber/webservices/GraphQLRepository.kt index d4ec39a4..027fc63a 100644 --- a/app/src/main/java/awais/instagrabber/webservices/GraphQLRepository.kt +++ b/app/src/main/java/awais/instagrabber/webservices/GraphQLRepository.kt @@ -1,12 +1,12 @@ package awais.instagrabber.webservices import android.util.Log +import awais.instagrabber.models.enums.FollowingType import awais.instagrabber.repositories.GraphQLService import awais.instagrabber.repositories.responses.* import awais.instagrabber.utils.Constants import awais.instagrabber.utils.ResponseBodyUtils import awais.instagrabber.utils.extensions.TAG -import com.google.gson.Gson import org.json.JSONException import org.json.JSONObject import java.util.* @@ -181,9 +181,9 @@ class GraphQLRepository(private val service: GraphQLService) { ): User { val response = service.getUser(username) val body = JSONObject(response - .split("", false, 2).get(0) - .trim().replace(Regex("};$"), "}")) + .split("").get(0) + .trim().replace(Regex("\\};$"), "}")) val userJson = body .getJSONObject("entry_data") .getJSONArray("ProfilePage") @@ -241,9 +241,9 @@ class GraphQLRepository(private val service: GraphQLService) { ): Hashtag { val response = service.getTag(tag) val body = JSONObject(response - .split("", false, 2).get(0) - .trim().replace(Regex("};$"), "}")) + .split("").get(0) + .trim().replace(Regex("\\};$"), "}")) .getJSONObject("entry_data") .getJSONArray("TagPage") .getJSONObject(0) @@ -265,8 +265,7 @@ class GraphQLRepository(private val service: GraphQLService) { ): Location { val response = service.getLocation(locationId) val body = JSONObject(response - .split("", false, 2).get(0) + .split("").get(1) .trim().replace(Regex("};$"), "}")) .getJSONObject("entry_data") .getJSONArray("LocationsPage")