Add support for sgnl:// proxy deep links.
This commit is contained in:
parent
64fe78ff9a
commit
524f3d6d08
3 changed files with 53 additions and 2 deletions
|
@ -261,6 +261,8 @@
|
||||||
<category android:name="android.intent.category.BROWSABLE" />
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
<data android:scheme="https"
|
<data android:scheme="https"
|
||||||
android:host="signal.tube" />
|
android:host="signal.tube" />
|
||||||
|
<data android:scheme="sgnl"
|
||||||
|
android:host="signal.tube" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
|
|
@ -103,11 +103,17 @@ public final class SignalProxyUtil {
|
||||||
* If this is a valid proxy deep link, this will return the embedded host. If not, it will return
|
* If this is a valid proxy deep link, this will return the embedded host. If not, it will return
|
||||||
* null.
|
* null.
|
||||||
*/
|
*/
|
||||||
public static @Nullable String parseHostFromProxyDeepLink(@NonNull String proxyLink) {
|
public static @Nullable String parseHostFromProxyDeepLink(@Nullable String proxyLink) {
|
||||||
|
if (proxyLink == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
URI uri = new URI(proxyLink);
|
URI uri = new URI(proxyLink);
|
||||||
|
|
||||||
if (!"https".equalsIgnoreCase(uri.getScheme())) {
|
if (!"https".equalsIgnoreCase(uri.getScheme()) &&
|
||||||
|
!"sgnl".equalsIgnoreCase(uri.getScheme()))
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
package org.thoughtcrime.securesms.util;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.junit.runners.Parameterized;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import static junit.framework.TestCase.assertEquals;
|
||||||
|
|
||||||
|
@RunWith(Parameterized.class)
|
||||||
|
public class SignalProxyUtilText_parseHostFromProxyDeepLink {
|
||||||
|
|
||||||
|
private final String input;
|
||||||
|
private final String output;
|
||||||
|
|
||||||
|
@Parameterized.Parameters
|
||||||
|
public static Collection<Object[]> data() {
|
||||||
|
return Arrays.asList(new Object[][]{
|
||||||
|
{ "https://signal.tube/#proxy.parker.org", "proxy.parker.org" },
|
||||||
|
{ "sgnl://signal.tube/#proxy.parker.org", "proxy.parker.org" },
|
||||||
|
{ "https://signal.tube/", null },
|
||||||
|
{ "https://signal.tube/#", null },
|
||||||
|
{ "sgnl://signal.tube/", null },
|
||||||
|
{ "sgnl://signal.tube/#", null },
|
||||||
|
{ "http://signal.tube/#proxy.parker.org", null },
|
||||||
|
{ "signal.tube/#proxy.parker.org", null },
|
||||||
|
{ "", null },
|
||||||
|
{ null, null }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public SignalProxyUtilText_parseHostFromProxyDeepLink(String input, String output) {
|
||||||
|
this.input = input;
|
||||||
|
this.output = output;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void parse() {
|
||||||
|
assertEquals(output, SignalProxyUtil.parseHostFromProxyDeepLink(input));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue