diff --git a/ui/analytics.js b/ui/analytics.js index 903202996..e5bc1fe43 100644 --- a/ui/analytics.js +++ b/ui/analytics.js @@ -6,6 +6,7 @@ import { history } from './store'; // @if TARGET='app' import Native from 'native'; import ElectronCookies from '@exponent/electron-cookies'; +import { generateInitialUrl } from 'util/url'; // @endif const isProduction = process.env.NODE_ENV === 'production'; @@ -253,7 +254,9 @@ analytics.pageView(window.location.pathname + window.location.search); // @if TARGET='app' ReactGA.set({ checkProtocolTask: null }); ReactGA.set({ location: 'https://lbry.tv' }); -analytics.pageView(window.location.pathname.split('.html')[1] + window.location.search || '/'); +analytics.pageView( + window.location.pathname.split('.html')[1] + window.location.search || generateInitialUrl(window.location.hash) +); // @endif; // Listen for url changes and report diff --git a/ui/store.js b/ui/store.js index a828c56db..57177410c 100644 --- a/ui/store.js +++ b/ui/store.js @@ -14,6 +14,7 @@ import { buildSharedStateMiddleware, ACTIONS as LBRY_REDUX_ACTIONS } from 'lbry- import { doGetSync, selectUserVerifiedEmail } from 'lbryinc'; import { getSavedPassword } from 'util/saved-passwords'; import { makeSelectClientSetting } from 'redux/selectors/settings'; +import { generateInitialUrl } from 'util/url'; function isFunction(object) { return typeof object === 'function'; @@ -96,14 +97,8 @@ const persistOptions = { let history; // @if TARGET='app' -let initialEntry = '/'; -let hash = window.location.hash; -if (hash) { - hash = hash.replace('#', ''); - initialEntry = hash.startsWith('/') ? hash : '/' + hash; -} history = createMemoryHistory({ - initialEntries: [initialEntry], + initialEntries: [generateInitialUrl(window.location.hash)], initialIndex: 0, }); // @endif diff --git a/ui/util/url.js b/ui/util/url.js index ada2c9a45..427c7e8af 100644 --- a/ui/util/url.js +++ b/ui/util/url.js @@ -61,3 +61,12 @@ exports.formatWebUrlIntoLbryUrl = (pathname, search) => { return appLink; }; + +exports.generateInitialUrl = hash => { + let url = '/'; + if (hash) { + hash = hash.replace('#', ''); + url = hash.startsWith('/') ? hash : '/' + hash; + } + return url; +};