encode share url parts
This commit is contained in:
parent
d9b8f0310a
commit
72ac5a5437
2 changed files with 15 additions and 13 deletions
|
@ -49,9 +49,7 @@ function SocialShare(props: Props) {
|
|||
const encodedLbryURL: string = generateEncodedLbryURL(SHARE_DOMAIN, lbryWebUrl, includeStartTime, startTimeSeconds);
|
||||
const shareUrl: string = generateShareUrl(
|
||||
SHARE_DOMAIN,
|
||||
lbryWebUrl,
|
||||
canonicalUrl,
|
||||
permanentUrl,
|
||||
lbryUrl,
|
||||
referralCode,
|
||||
rewardsApproved,
|
||||
includeStartTime,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Can't use aliases here because we're doing exports/require
|
||||
const PAGES = require('../constants/pages');
|
||||
const { parseURI, buildURI } = require('lbry-redux');
|
||||
|
||||
exports.formatLbryUrlForWeb = uri => {
|
||||
let newUrl = uri.replace('lbry://', '/').replace(/#/g, ':');
|
||||
|
@ -91,16 +92,7 @@ exports.generateEncodedLbryURL = (domain, lbryWebUrl, includeStartTime, startTim
|
|||
return `${domain}/${encodedPart}`;
|
||||
};
|
||||
|
||||
exports.generateShareUrl = (
|
||||
domain,
|
||||
lbryWebUrl,
|
||||
canonicalUrl,
|
||||
permanentUrl,
|
||||
referralCode,
|
||||
rewardsApproved,
|
||||
includeStartTime,
|
||||
startTime
|
||||
) => {
|
||||
exports.generateShareUrl = (domain, lbryUrl, referralCode, rewardsApproved, includeStartTime, startTime) => {
|
||||
let urlParams = new URLSearchParams();
|
||||
if (referralCode && rewardsApproved) {
|
||||
urlParams.append('r', referralCode);
|
||||
|
@ -112,6 +104,18 @@ exports.generateShareUrl = (
|
|||
|
||||
const urlParamsString = urlParams.toString();
|
||||
|
||||
const { streamName, streamClaimId, channelName, channelClaimId } = parseURI(lbryUrl);
|
||||
|
||||
let uriParts = {
|
||||
...(streamName ? { streamName: encodeURIComponent(streamName) } : {}),
|
||||
...(streamClaimId ? { streamClaimId } : {}),
|
||||
...(channelName ? { channelName: encodeURIComponent(channelName) } : {}),
|
||||
...(channelClaimId ? { channelClaimId } : {}),
|
||||
};
|
||||
|
||||
const encodedUrl = buildURI(uriParts, false);
|
||||
const lbryWebUrl = encodedUrl.replace(/#/g, ':');
|
||||
|
||||
const url = `${domain}/${lbryWebUrl}` + (urlParamsString === '' ? '' : `?${urlParamsString}`);
|
||||
return url;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue