From 2f51f79730aeb60cb4763aacb0bdf54c2f0fe4f8 Mon Sep 17 00:00:00 2001
From: Daniel Dominguez <danielfromarg@gmail.com>
Date: Mon, 21 May 2018 14:20:22 -0300
Subject: [PATCH 1/2] Add function to convert an URI to  an url that can be
 shared and opened with lbry-app.

---
 src/index.js   |  1 +
 src/lbryURI.js | 15 +++++++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/index.js b/src/index.js
index c6f8ab7..bddde8b 100644
--- a/src/index.js
+++ b/src/index.js
@@ -22,6 +22,7 @@ export {
   isURIValid,
   isURIClaimable,
   isNameValid,
+  convertToShareLink,
 } from 'lbryURI';
 
 // actions
diff --git a/src/lbryURI.js b/src/lbryURI.js
index 9fd136b..c755357 100644
--- a/src/lbryURI.js
+++ b/src/lbryURI.js
@@ -145,7 +145,7 @@ export function parseURI(URI, requireProto = false) {
  *
  * The channelName key will accept names with or without the @ prefix.
  */
-export function buildURI(URIObj, includeProto = true) {
+export function buildURI(URIObj, includeProto = true, protoDefault = 'lbry://') {
   const { claimId, claimSequence, bidPosition, contentName, channelName } = URIObj;
 
   let { claimName, path } = URIObj;
@@ -179,7 +179,7 @@ export function buildURI(URIObj, includeProto = true) {
   }
 
   return (
-    (includeProto ? 'lbry://' : '') +
+    (includeProto ? protoDefault : '') +
     claimName +
     (claimId ? `#${claimId}` : '') +
     (claimSequence ? `:${claimSequence}` : '') +
@@ -228,3 +228,14 @@ export function isURIClaimable(URI) {
     !parts.path
   );
 }
+
+export function convertToShareLink(URI) {
+  if (URI.match(/pending_claim/)) return URI;
+
+  const { claimName, path, bidPosition, claimSequence, claimId } = parseURI(URI);
+  return buildURI(
+    { claimName, path, claimSequence, bidPosition, claimId },
+    true,
+    'https://open.lbry.io/'
+  );
+}

From 878d9b758a8088be83cc8808191532e36f0e5908 Mon Sep 17 00:00:00 2001
From: Daniel Dominguez <danielfromarg@gmail.com>
Date: Wed, 23 May 2018 15:17:26 -0300
Subject: [PATCH 2/2] Refactor/delete useless code on convertToShareLink
 function.

---
 src/lbryURI.js | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/src/lbryURI.js b/src/lbryURI.js
index c755357..24b20b1 100644
--- a/src/lbryURI.js
+++ b/src/lbryURI.js
@@ -230,12 +230,5 @@ export function isURIClaimable(URI) {
 }
 
 export function convertToShareLink(URI) {
-  if (URI.match(/pending_claim/)) return URI;
-
-  const { claimName, path, bidPosition, claimSequence, claimId } = parseURI(URI);
-  return buildURI(
-    { claimName, path, claimSequence, bidPosition, claimId },
-    true,
-    'https://open.lbry.io/'
-  );
+  return buildURI(parseURI(URI), true, 'https://open.lbry.io/');
 }