only redirect on show page if in lbry.tv land

Fixes crash when app is served from webcache.googleusercontent.com
This commit is contained in:
Sean Yesmunt 2020-08-17 23:41:28 -04:00
parent d2ca72e246
commit 0ec569f020

View file

@ -1,4 +1,5 @@
// @flow
import { DOMAIN } from 'config';
import React, { useEffect } from 'react';
import { Redirect } from 'react-router-dom';
import BusyIndicator from 'component/common/busy-indicator';
@ -48,7 +49,9 @@ function ShowPage(props: Props) {
// @if TARGET='web'
if (canonicalUrl) {
const canonicalUrlPath = '/' + canonicalUrl.replace(/^lbry:\/\//, '').replace(/#/g, ':');
if (canonicalUrlPath !== window.location.pathname) {
// Only redirect if we are in lbry.tv land
// replaceState will fail if on a different domain (like webcache.googleusercontent.com)
if (canonicalUrlPath !== window.location.pathname && DOMAIN === window.location.hostname) {
history.replaceState(history.state, '', canonicalUrlPath);
}
}