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)) {