DocSpace-client/packages/shared/utils/tryRedirectTo.ts

15 lines
248 B
TypeScript

function tryRedirectTo(page: string) {
if (
window.location.pathname === page ||
window.location.pathname.indexOf(page) !== -1
) {
return false;
}
window.location.replace(page);
return true;
}
export default tryRedirectTo;