bugfixes around display of permanentURIs
This commit is contained in:
parent
f790ae19de
commit
20dc54ba05
5 changed files with 36 additions and 14 deletions
|
@ -9,6 +9,8 @@ import HorizontalSplit from '@components/HorizontalSplit';
|
|||
import siteConfig from '@config/siteConfig.json';
|
||||
import createCanonicalLink from '../../../../utils/createCanonicalLink';
|
||||
import AssetInfoFooter from '../../components/AssetInfoFooter/index';
|
||||
import { createPermanentURI } from '@clientutils/createPermanentURI';
|
||||
|
||||
const { details: { host } } = siteConfig;
|
||||
|
||||
class AssetInfo extends React.Component {
|
||||
|
@ -121,7 +123,7 @@ class AssetInfo extends React.Component {
|
|||
content={
|
||||
<ClickToCopy
|
||||
id={'lbry-permanent-url'}
|
||||
value={`${channelName}#${certificateId}/${name}`}
|
||||
value={`${createPermanentURI(asset)}`}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
|
@ -142,7 +144,7 @@ class AssetInfo extends React.Component {
|
|||
</a>
|
||||
<a
|
||||
className={'link--primary'}
|
||||
href={`https://open.lbry.io/${channelName}#${certificateId}/${name}`}
|
||||
href={`https://open.lbry.io/${createPermanentURI(asset)}`}
|
||||
download={name}
|
||||
>
|
||||
LBRY URL
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
import {connect} from 'react-redux';
|
||||
import View from './view';
|
||||
import {selectAsset} from '../../selectors/show';
|
||||
import {buildURI} from '../../utils/buildURI';
|
||||
import {createPermanentURI} from '@clientutils/createPermanentURI';
|
||||
|
||||
const mapStateToProps = props => {
|
||||
const { show, publish } = props;
|
||||
const asset = selectAsset(show);
|
||||
let uri;
|
||||
if (asset) {
|
||||
uri = `lbry://${buildURI(asset)}`;
|
||||
uri = `lbry://${createPermanentURI(asset)}`;
|
||||
}
|
||||
return {
|
||||
disabled : publish.disabled,
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
export const buildURI = asset => {
|
||||
let channelName, certificateId, name, claimId;
|
||||
if (asset.claimData) {
|
||||
({ channelName, certificateId, name, claimId } = asset.claimData);
|
||||
}
|
||||
if (channelName) {
|
||||
return `${channelName}:${certificateId}/${name}`;
|
||||
}
|
||||
return `${claimId}/${name}`;
|
||||
};
|
24
client/src/utils/createPermanentURI.js
Normal file
24
client/src/utils/createPermanentURI.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
{ channelName, certificateId, name, claimId } = { claimData } = asset
|
||||
|
||||
permanentUrl for a channel
|
||||
@channelName#certificateId
|
||||
|
||||
permanentUrl for an asset in a channel
|
||||
@channelName#certificateId/name
|
||||
|
||||
permanentUrl for an asset published anonymously
|
||||
name#claimId
|
||||
*/
|
||||
|
||||
export const createPermanentURI = asset => {
|
||||
let channelName, certificateId, name, claimId;
|
||||
if (asset.claimData) {
|
||||
({ channelName, certificateId, name, claimId } = asset.claimData);
|
||||
}
|
||||
else return 'Error: unknown asset at createPermanentURI.js';
|
||||
if (channelName) {
|
||||
return `${channelName}#${certificateId}/${name}`;
|
||||
}
|
||||
return `${name}#${claimId}`;
|
||||
};
|
|
@ -34,6 +34,11 @@ module.exports = () => {
|
|||
moduleAliases['@config'] = resolve('site/config');
|
||||
moduleAliases['@private'] = resolve('site/private');
|
||||
|
||||
// aliases for utils
|
||||
moduleAliases['@globalutils'] = resolve('utils');
|
||||
moduleAliases['@clientutils'] = resolve(`${DEFAULT_ROOT}/utils`);
|
||||
// moduleAliases['@serverutils'] = resolve('server/utils');
|
||||
|
||||
// create specific aliases for locally defined components in the following folders
|
||||
moduleAliases = addAliasesForCustomComponentFolder('containers', moduleAliases);
|
||||
moduleAliases = addAliasesForCustomComponentFolder('components', moduleAliases);
|
||||
|
@ -48,6 +53,7 @@ module.exports = () => {
|
|||
moduleAliases['@sagas'] = resolve(`${DEFAULT_ROOT}/sagas`);
|
||||
moduleAliases['@app'] = resolve(`${DEFAULT_ROOT}/app.js`);
|
||||
|
||||
|
||||
// return finished aliases
|
||||
return moduleAliases;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue