Merge pull request #27 from dan1d/share-link-uri

Add function to convert an URI to  an url that can be shared and opened with lbry-app
This commit is contained in:
Sean Yesmunt 2018-05-30 10:19:15 -04:00 committed by GitHub
commit 0c6bffccc3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View file

@ -23,6 +23,7 @@ export {
isURIValid, isURIValid,
isURIClaimable, isURIClaimable,
isNameValid, isNameValid,
convertToShareLink,
} from 'lbryURI'; } from 'lbryURI';
// actions // actions

View file

@ -145,7 +145,7 @@ export function parseURI(URI, requireProto = false) {
* *
* The channelName key will accept names with or without the @ prefix. * 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; const { claimId, claimSequence, bidPosition, contentName, channelName } = URIObj;
let { claimName, path } = URIObj; let { claimName, path } = URIObj;
@ -179,7 +179,7 @@ export function buildURI(URIObj, includeProto = true) {
} }
return ( return (
(includeProto ? 'lbry://' : '') + (includeProto ? protoDefault : '') +
claimName + claimName +
(claimId ? `#${claimId}` : '') + (claimId ? `#${claimId}` : '') +
(claimSequence ? `:${claimSequence}` : '') + (claimSequence ? `:${claimSequence}` : '') +
@ -228,3 +228,7 @@ export function isURIClaimable(URI) {
!parts.path !parts.path
); );
} }
export function convertToShareLink(URI) {
return buildURI(parseURI(URI), true, 'https://open.lbry.io/');
}