From e8a5ab8307ae9c02e106018a478bf0b2c2f7ec28 Mon Sep 17 00:00:00 2001 From: Javi Rueda Date: Mon, 13 Jul 2020 19:00:12 +0200 Subject: [PATCH 1/2] Add open.lbry.com deep-links --- app/src/main/AndroidManifest.xml | 7 +++ .../java/io/lbry/browser/utils/LbryUri.java | 49 ++++++++++++------- 2 files changed, 38 insertions(+), 18 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 28eca8a7..7ac0cf49 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -56,6 +56,13 @@ + + + + + + + -1) { throw new LbryUriException("URL cannot include a space."); } } - String streamOrChannelName = components.get(1); - String primaryModSeparator = components.get(2); - String primaryModValue = components.get(3); - String possibleStreamName = components.get(5); - String secondaryModSeparator = components.get(6); - String secondaryModValue = components.get(7); + String streamOrChannelName = components.get(2); + String primaryModSeparator = components.get(3); + String primaryModValue = components.get(4); + String possibleStreamName = components.get(6); + String secondaryModSeparator = components.get(7); + String secondaryModValue = components.get(8); boolean includesChannel = streamOrChannelName.startsWith("@"); boolean isChannel = includesChannel && Helper.isNullOrEmpty(possibleStreamName); String channelName = includesChannel && streamOrChannelName.length() > 1 ? streamOrChannelName.substring(1) : null; + + // It would have thrown already on the RegEx parser if protocol value was incorrect + // open.lbry.com uses ':' as ModSeparators while lbry:// expects '#' + if (components.get(1).equals("open.lbry.com/")) { + if (primaryModSeparator.equals(":")) + primaryModSeparator = "#"; + if (secondaryModSeparator.equals(":")) + secondaryModSeparator = "#"; + } + if (includesChannel) { if (Helper.isNullOrEmpty(channelName)) { throw new LbryUriException("No channel name after @."); @@ -147,7 +160,7 @@ public class LbryUri { LbryUri uri = new LbryUri(); uri.setChannel(isChannel); - uri.setPath(Helper.join(components.subList(1, components.size()), "")); + uri.setPath(Helper.join(components.subList(2, components.size()), "")); uri.setStreamName(streamName); uri.setStreamClaimId(streamClaimId); uri.setChannelName(channelName); From 481c50f465b3ada64a675786dc0937847e7c5ebb Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Fri, 17 Jul 2020 11:39:59 +0100 Subject: [PATCH 2/2] fix open.lbry.com regex --- app/src/main/java/io/lbry/browser/utils/LbryUri.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/lbry/browser/utils/LbryUri.java b/app/src/main/java/io/lbry/browser/utils/LbryUri.java index d1d6e30c..94458cfa 100644 --- a/app/src/main/java/io/lbry/browser/utils/LbryUri.java +++ b/app/src/main/java/io/lbry/browser/utils/LbryUri.java @@ -18,7 +18,7 @@ public class LbryUri { public static final int CLAIM_ID_MAX_LENGTH = 40; private static final String REGEX_PART_PROTOCOL = "^((?:lbry://|https://)?)"; - private static final String REGEX_PART_HOST = "^((?:open.lbry.com/)?)"; + private static final String REGEX_PART_HOST = "((?:open.lbry.com/)?)"; private static final String REGEX_PART_STREAM_OR_CHANNEL_NAME = "([^:$#/]*)"; private static final String REGEX_PART_MODIFIER_SEPARATOR = "([:$#]?)([^/]*)"; private static final String QUERY_STRING_BREAKER = "^([\\S]+)([?][\\S]*)";