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:
commit
0c6bffccc3
2 changed files with 7 additions and 2 deletions
|
@ -23,6 +23,7 @@ export {
|
|||
isURIValid,
|
||||
isURIClaimable,
|
||||
isNameValid,
|
||||
convertToShareLink,
|
||||
} from 'lbryURI';
|
||||
|
||||
// actions
|
||||
|
|
|
@ -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,7 @@ export function isURIClaimable(URI) {
|
|||
!parts.path
|
||||
);
|
||||
}
|
||||
|
||||
export function convertToShareLink(URI) {
|
||||
return buildURI(parseURI(URI), true, 'https://open.lbry.io/');
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue