From 871103cac1c8d94b7910dedf53387c738546f789 Mon Sep 17 00:00:00 2001 From: arkon Date: Thu, 25 Jul 2024 08:23:40 -0400 Subject: [PATCH] Handle more common redirects --- .../shouko/feature/LinkCleaner.kt | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/xyz/ivaniskandar/shouko/feature/LinkCleaner.kt b/app/src/main/java/xyz/ivaniskandar/shouko/feature/LinkCleaner.kt index 9d6b751..099c461 100644 --- a/app/src/main/java/xyz/ivaniskandar/shouko/feature/LinkCleaner.kt +++ b/app/src/main/java/xyz/ivaniskandar/shouko/feature/LinkCleaner.kt @@ -34,11 +34,23 @@ object LinkCleaner { } "fxtwitter.com", "fixupx.com", "fixvx.com", "vxtwitter.com" -> { - oldUri = "https://x.com${oldUri.path}".toUri() + oldUri = oldUri.withHost("x.com") } "phixiv.net" -> { - oldUri = "https://www.pixiv.net${oldUri.path}".toUri() + oldUri = oldUri.withHost("www.pixiv.net") + } + + "vxreddit.com" -> { + oldUri = oldUri.withHost("www.reddit.com") + } + + "ddinstagram.com" -> { + oldUri = oldUri.withHost("instagram.com") + } + + "tnktok.com" -> { + oldUri = oldUri.withHost("tiktok.com") } } val port = oldUri.port.takeIf { it != -1 }?.let { ":$it" } ?: "" @@ -56,6 +68,10 @@ object LinkCleaner { } } + private fun Uri.withHost(host: String): Uri { + return "https://$host$path".toUri() + } + private fun String?.urlDecode(): Uri { return URLDecoder.decode(this, "UTF-8").toUri() }