From 65167f643fab228441422eeb7bfcef6827df5916 Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 10 Apr 2020 18:03:04 +0200 Subject: [PATCH] Fix issue #10 --- .../nitterizeme/TransformActivity.java | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/app/fedilab/nitterizeme/TransformActivity.java b/app/src/main/java/app/fedilab/nitterizeme/TransformActivity.java index 7fc9d9c..e781b8a 100644 --- a/app/src/main/java/app/fedilab/nitterizeme/TransformActivity.java +++ b/app/src/main/java/app/fedilab/nitterizeme/TransformActivity.java @@ -475,18 +475,20 @@ public class TransformActivity extends Activity { if (nitter_enabled) { String nitterHost = sharedpreferences.getString(MainActivity.SET_NITTER_HOST, MainActivity.DEFAULT_NITTER_HOST).toLowerCase(); assert host != null; - if (host.compareTo("pbs.twimg.com") != 0 || host.compareTo("pic.twitter.com") != 0) { - Matcher matcher = nitterPattern.matcher(url); - while (matcher.find()) { - final String nitter_directory = matcher.group(2); - newUrl = "https://" + nitterHost + nitter_directory; - } - } else { + if (host.compareTo("pbs.twimg.com") == 0 || host.compareTo("pic.twitter.com") == 0) { try { newUrl = "https://" + nitterHost + "/pic/" + URLEncoder.encode(url, "utf-8"); } catch (UnsupportedEncodingException e) { newUrl = "https://" + nitterHost + "/pic/" + url; } + }else if(url.contains("/search?")){ + newUrl = url.replace(host, nitterHost); + } else { + Matcher matcher = nitterPattern.matcher(url); + while (matcher.find()) { + final String nitter_directory = matcher.group(2); + newUrl = "https://" + nitterHost + nitter_directory; + } } return newUrl; } else { @@ -621,18 +623,20 @@ public class TransformActivity extends Activity { String nitterHost = sharedpreferences.getString(MainActivity.SET_NITTER_HOST, MainActivity.DEFAULT_NITTER_HOST).toLowerCase(); assert host != null; - if (host.compareTo("pbs.twimg.com") != 0 || host.compareTo("pic.twitter.com") != 0) { - Matcher matcher = nitterPattern.matcher(url); - while (matcher.find()) { - final String nitter_directory = matcher.group(2); - newUrl = "https://" + nitterHost + nitter_directory; - } - } else { + if (host.compareTo("pbs.twimg.com") == 0 || host.compareTo("pic.twitter.com") == 0) { try { newUrl = "https://" + nitterHost + "/pic/" + URLEncoder.encode(url, "utf-8"); } catch (UnsupportedEncodingException e) { newUrl = "https://" + nitterHost + "/pic/" + url; } + }else if(url.contains("/search?")){ + newUrl = url.replace(host, nitterHost); + } else { + Matcher matcher = nitterPattern.matcher(url); + while (matcher.find()) { + final String nitter_directory = matcher.group(2); + newUrl = "https://" + nitterHost + nitter_directory; + } } } } else if (Arrays.asList(instagram_domains).contains(host)) {