From e8a5ab8307ae9c02e106018a478bf0b2c2f7ec28 Mon Sep 17 00:00:00 2001 From: Javi Rueda Date: Mon, 13 Jul 2020 19:00:12 +0200 Subject: [PATCH] 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);