From b7a40b7b39a9b678df0899b7bc731e2535161d5a Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Wed, 6 Jan 2021 13:44:28 -0500 Subject: [PATCH] close #532 --- .../awais/instagrabber/utils/ResponseBodyUtils.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/utils/ResponseBodyUtils.java b/app/src/main/java/awais/instagrabber/utils/ResponseBodyUtils.java index 12505689..d161609f 100644 --- a/app/src/main/java/awais/instagrabber/utils/ResponseBodyUtils.java +++ b/app/src/main/java/awais/instagrabber/utils/ResponseBodyUtils.java @@ -1,5 +1,6 @@ package awais.instagrabber.utils; +import android.net.Uri; import android.util.Log; import android.util.Pair; @@ -962,10 +963,15 @@ public final class ResponseBodyUtils { } if (data.has("story_cta") && data.has("link_text")) { JSONObject tappableObject = data.getJSONArray("story_cta").getJSONObject(0).getJSONArray("links").getJSONObject(0); - String swipeUpUrl = tappableObject.getString("webUri"); - if (swipeUpUrl.startsWith("http")) { - model.setSwipeUp(new SwipeUpModel(swipeUpUrl, data.getString("link_text"))); + String swipeUpUrl = tappableObject.optString("webUri"); + final String backupSwipeUpUrl = swipeUpUrl; + if (swipeUpUrl != null && swipeUpUrl.startsWith("https://l.instagram.com/") { + swipeUpUrl = Uri.parse(swipeUpUrl).getQueryParameter("u"); } + if (swipeUpUrl != null && swipeUpUrl.startsWith("http")) + model.setSwipeUp(new SwipeUpModel(swipeUpUrl, data.getString("link_text"))); + else if (backupSwipeUpUrl != null && backupSwipeUpUrl.startsWith("http")) + model.setSwipeUp(new SwipeUpModel(backupSwipeUpUrl, data.getString("link_text"))); } if (data.has("story_sliders")) { final JSONObject tappableObject = data.getJSONArray("story_sliders").getJSONObject(0)