diff --git a/ShareWithTitle/src/main/java/net/crystalyx/sharewithtitle/MainActivity.java b/ShareWithTitle/src/main/java/net/crystalyx/sharewithtitle/MainActivity.java index 5326317..b0b80cd 100644 --- a/ShareWithTitle/src/main/java/net/crystalyx/sharewithtitle/MainActivity.java +++ b/ShareWithTitle/src/main/java/net/crystalyx/sharewithtitle/MainActivity.java @@ -6,6 +6,7 @@ import android.os.Bundle; import android.widget.Toast; import java.net.MalformedURLException; +import java.net.URI; import java.net.URL; public class MainActivity extends Activity { @@ -26,27 +27,15 @@ public class MainActivity extends Activity { private void handleUrl(String textUrl) { URL originalUrl; - URL fixedUrl; try { - originalUrl = new URL(textUrl); - - switch (originalUrl.getHost()) { - case "twitter.com": - case "t.co": - case "x.com": - fixedUrl = new URL(originalUrl.getProtocol(), "nitter.net", originalUrl.getPort(), originalUrl.getFile()); - break; - default: - fixedUrl = originalUrl; - break; - } - } catch (MalformedURLException e) { + originalUrl = new URI(textUrl).toURL(); + } catch (Exception e) { Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show(); return; } - HttpThreadHandler handler = new HttpThreadHandler(fixedUrl); + HttpThreadHandler handler = new HttpThreadHandler(originalUrl); Thread job = new Thread(handler); job.start();