fix canonical redirect

This commit is contained in:
zeppi 2021-06-11 17:46:52 -04:00 committed by jessopb
parent 5680b19dc8
commit e40aa84a40

View file

@ -84,7 +84,12 @@ function ShowPage(props: Props) {
// 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);
const urlParams = new URLSearchParams(search);
if (urlParams.get(COLLECTIONS_CONSTS.COLLECTION_ID)) {
const listId = urlParams.get(COLLECTIONS_CONSTS.COLLECTION_ID) || '';
urlParams.set(COLLECTIONS_CONSTS.COLLECTION_ID, listId);
}
history.replaceState(history.state, '', `${canonicalUrlPath}?${urlParams.toString()}`);
}
}
// @endif