This commit is contained in:
Jeremy Kauffman 2019-10-13 13:19:39 -04:00 committed by Sean Yesmunt
parent c35df624e3
commit 4ea43df42b
3 changed files with 15 additions and 1 deletions

View file

@ -74,6 +74,10 @@ app.get('*', async (req, res) => {
return res.redirect(301, req.url.replace(/([^/:]+)\/([^:/]+)/, '$1:$2')); // test against urlPath, but use req.url to retain parameters
}
if (urlPath.endsWith('/') && urlPath.length > 1) {
return res.redirect(301, req.url.replace(/\/$/, ''));
}
if (urlPath.length > 0 && urlPath[0] !== '$') {
const { isChannel, streamName, channelName, channelClaimId, streamClaimId } = parseURI(urlPath.replace(/:/g, '#'));
const claimName = isChannel ? '@' + channelName : streamName;

View file

@ -141,7 +141,7 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
if (onClick) {
onClick(e);
} else if ((isChannel || title) && !pending) {
history.push(formatLbryUriForWeb(uri));
history.push(formatLbryUriForWeb(claim && claim.canonical_url ? claim.canonical_url : uri));
}
}

View file

@ -29,6 +29,16 @@ class ShowPage extends React.PureComponent<Props> {
componentDidUpdate() {
const { isResolvingUri, resolveUri, claim, uri } = this.props;
// @if TARGET='web'
if (claim && claim.canonical_url) {
const canonicalUrlPath = '/' + claim.canonical_url.replace(/^lbry:\/\//, '').replace(/#/g, ':');
if (canonicalUrlPath !== window.location.pathname) {
history.replaceState(history.state, '', canonicalUrlPath);
}
}
// @endif
if (!isResolvingUri && uri && claim === undefined) {
resolveUri(uri);
}