Skip to content

Commit

Permalink
Handle more common redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
arkon committed Jul 25, 2024
1 parent b5ab9c9 commit 871103c
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions app/src/main/java/xyz/ivaniskandar/shouko/feature/LinkCleaner.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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" } ?: ""
Expand All @@ -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()
}
Expand Down

0 comments on commit 871103c

Please sign in to comment.