Skip to content

Commit 7563990

Browse files
authored
fix(X / Twitter - Change link sharing domain): Resolve duplicate patch option (#6119)
1 parent 4b605eb commit 7563990

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

extensions/twitter/src/main/java/app/revanced/twitter/patches/links/ChangeLinkSharingDomainPatch.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
@SuppressWarnings("unused")
44
public final class ChangeLinkSharingDomainPatch {
5-
private static final String LINK_FORMAT = "%s/%s/status/%s";
5+
private static final String LINK_FORMAT = "https://%s/%s/status/%s";
66

77
/**
88
* Method is modified during patching. Do not change.

patches/src/main/kotlin/app/revanced/patches/twitter/misc/links/ChangeLinkSharingDomainPatch.kt

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import java.util.logging.Logger
1515

1616
internal const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/twitter/patches/links/ChangeLinkSharingDomainPatch;"
1717

18-
internal val domainNameOption by stringOption(
18+
internal val domainNameOption = stringOption(
1919
key = "domainName",
20-
default = "https://fxtwitter.com",
20+
default = "fxtwitter.com",
2121
title = "Domain name",
2222
description = "The domain name to use when sharing links.",
2323
required = true,
@@ -28,7 +28,7 @@ internal val domainNameOption by stringOption(
2828
// may not allow network connections or the network may be down.
2929
try {
3030
InetAddress.getByName(it)
31-
} catch (e: UnknownHostException) {
31+
} catch (_: UnknownHostException) {
3232
Logger.getLogger(this::class.java.name).warning(
3333
"Host \"$it\" did not resolve to any domain."
3434
)
@@ -38,13 +38,9 @@ internal val domainNameOption by stringOption(
3838

3939
internal val changeLinkSharingDomainResourcePatch = resourcePatch {
4040
execute {
41-
val domainName = domainNameOption!!
41+
val domainName = domainNameOption.value!!
4242

43-
val shareLinkTemplate = if (domainName.endsWith("/")) {
44-
"$domainName%1\$s/status/%2\$s"
45-
} else {
46-
"$domainName/%1\$s/status/%2\$s"
47-
}
43+
val shareLinkTemplate = "https://$domainName/%1\$s/status/%2\$s"
4844

4945
document("res/values/strings.xml").use { document ->
5046
document.documentElement.childNodes.findElementByAttributeValueOrThrow(
@@ -58,7 +54,8 @@ internal val changeLinkSharingDomainResourcePatch = resourcePatch {
5854
@Suppress("unused")
5955
val changeLinkSharingDomainPatch = bytecodePatch(
6056
name = PATCH_NAME_CHANGE_LINK_SHARING_DOMAIN,
61-
description = PATCH_DESCRIPTION_CHANGE_LINK_SHARING_DOMAIN
57+
description = PATCH_DESCRIPTION_CHANGE_LINK_SHARING_DOMAIN,
58+
use = false
6259
) {
6360
dependsOn(
6461
changeLinkSharingDomainResourcePatch,
@@ -72,11 +69,11 @@ val changeLinkSharingDomainPatch = bytecodePatch(
7269
)
7370
)
7471

75-
execute {
76-
val domainName = domainNameOption!!
72+
val domainName by domainNameOption()
7773

74+
execute {
7875
// Replace the domain name in the link sharing extension methods.
79-
linkSharingDomainHelperFingerprint.method.returnEarly(domainName)
76+
linkSharingDomainHelperFingerprint.method.returnEarly(domainName!!)
8077

8178
// Replace the domain name when copying a link with "Copy link" button.
8279
linkBuilderFingerprint.method.addInstructions(

0 commit comments

Comments
 (0)