diff --git a/.env.defaults b/.env.defaults index 4a59b0967..dac523910 100644 --- a/.env.defaults +++ b/.env.defaults @@ -13,6 +13,8 @@ WELCOME_VERSION=1.0 # Custom Site info DOMAIN=lbry.tv +## SHARE_DOMAIN_URL=https://lbry.xy +SHARE_DOMAIN_URL=https://open.lbry.com URL=https://lbry.tv # UI SITE_TITLE=lbry.tv diff --git a/config.js b/config.js index b35cda7f8..00dca2ff5 100644 --- a/config.js +++ b/config.js @@ -12,6 +12,7 @@ const config = { LBRY_WEB_BUFFER_API: process.env.LBRY_WEB_BUFFER_API, WELCOME_VERSION: process.env.WELCOME_VERSION, DOMAIN: process.env.DOMAIN, + SHARE_DOMAIN_URL: process.env.SHARE_DOMAIN_URL, URL: process.env.URL, SITE_TITLE: process.env.SITE_TITLE, SITE_NAME: process.env.SITE_NAME, diff --git a/ui/component/socialShare/view.jsx b/ui/component/socialShare/view.jsx index 22ca6d88a..4e8996fe0 100644 --- a/ui/component/socialShare/view.jsx +++ b/ui/component/socialShare/view.jsx @@ -8,12 +8,8 @@ import { generateDownloadUrl } from 'util/web'; import { useIsMobile } from 'effects/use-screensize'; import { FormField } from 'component/common/form'; import { hmsToSeconds, secondsToHms } from 'util/time'; -import { - generateLbryContentUrl, - generateLbryWebUrl, - generateEncodedLbryURL, - generateOpenDotLbryDotComUrl, -} from 'util/url'; +import { generateLbryContentUrl, generateLbryWebUrl, generateEncodedLbryURL, generateShareUrl } from 'util/url'; +import { SHARE_DOMAIN_URL } from 'config'; const IOS = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform); const SUPPORTS_SHARE_API = typeof navigator.share !== 'undefined'; @@ -47,12 +43,16 @@ function SocialShare(props: Props) { const isAudio = isStream && claim.value.stream_type === 'audio'; const showStartAt = isVideo || isAudio; const rewardsApproved = user && user.is_reward_approved; - const OPEN_URL = 'https://open.lbry.com/'; const lbryUrl: string = generateLbryContentUrl(canonicalUrl, permanentUrl); const lbryWebUrl: string = generateLbryWebUrl(lbryUrl); - const encodedLbryURL: string = generateEncodedLbryURL(OPEN_URL, lbryWebUrl, includeStartTime, startTimeSeconds); - const openDotLbryDotComUrl: string = generateOpenDotLbryDotComUrl( - OPEN_URL, + const encodedLbryURL: string = generateEncodedLbryURL( + SHARE_DOMAIN_URL, + lbryWebUrl, + includeStartTime, + startTimeSeconds + ); + const shareUrl: string = generateShareUrl( + SHARE_DOMAIN_URL, lbryWebUrl, canonicalUrl, permanentUrl, @@ -74,7 +74,7 @@ function SocialShare(props: Props) { return ( - + {showStartAt && (
{ return lbryUrl.replace(/#/g, ':'); }; -exports.generateEncodedLbryURL = (openUrl, lbryWebUrl, includeStartTime, startTime) => { +exports.generateEncodedLbryURL = (domain, lbryWebUrl, includeStartTime, startTime) => { const queryParam = includeStartTime ? `?t=${startTime}` : ''; const encodedPart = encodeURIComponent(`${lbryWebUrl}${queryParam}`); - return `${openUrl}${encodedPart}`; + return `${domain}/${encodedPart}`; }; -exports.generateOpenDotLbryDotComUrl = ( - openUrl, +exports.generateShareUrl = ( + domain, lbryWebUrl, canonicalUrl, permanentUrl, @@ -111,6 +111,6 @@ exports.generateOpenDotLbryDotComUrl = ( } const urlParamsString = urlParams.toString(); - const url = `${openUrl}${lbryWebUrl}` + (urlParamsString === '' ? '' : `?${urlParamsString}`); + const url = `${domain}/${lbryWebUrl}` + (urlParamsString === '' ? '' : `?${urlParamsString}`); return url; };