diff --git a/src/actions/app.ts b/src/actions/app.ts index 6302233259..853a09f885 100644 --- a/src/actions/app.ts +++ b/src/actions/app.ts @@ -150,8 +150,12 @@ export function setupInitialUrlState( return; } - // Validate the initial URL state. We can't refresh on a from-file URL. - if (urlState.dataSource === 'from-file') { + // Validate the initial URL state. We can't refresh on from-file or + // unpublished URLs. + if ( + urlState.dataSource === 'from-file' || + urlState.dataSource === 'unpublished' + ) { urlState = null; } diff --git a/src/actions/receive-profile.ts b/src/actions/receive-profile.ts index 0bd60fb0ec..bfca2b3ba0 100644 --- a/src/actions/receive-profile.ts +++ b/src/actions/receive-profile.ts @@ -1400,9 +1400,10 @@ export function retrieveProfileForRawUrl( } let dataSource = ensureIsValidDataSource(possibleDataSource); - if (dataSource === 'from-file') { - // Redirect to 'none' if `dataSource` is 'from-file' since initial urls can't - // be 'from-file' and needs to be redirected to home page. + // Redirect to 'none' for from-file and unpublished data sources since initial + // urls can't be 'from-file' or 'unpublished' and need to be redirected to + // home page. 'unpublished' is a transient state after profile deletion. + if (dataSource === 'from-file' || dataSource === 'unpublished') { dataSource = 'none'; } dispatch(setDataSource(dataSource)); @@ -1475,7 +1476,6 @@ export function retrieveProfileForRawUrl( case 'uploaded-recordings': case 'none': case 'local': - case 'unpublished': // There is no profile to download for these datasources. break; default: diff --git a/src/test/store/receive-profile.test.ts b/src/test/store/receive-profile.test.ts index b00a183beb..13a5618f8b 100644 --- a/src/test/store/receive-profile.test.ts +++ b/src/test/store/receive-profile.test.ts @@ -2190,6 +2190,20 @@ describe('actions/receive-profile', function () { }); } ); + + it('redirects unpublished initial URLs to home page', async function () { + const { getState } = await setup({ + pathname: '/unpublished/', + search: '', + hash: '', + }); + + // The data source should be redirected from 'unpublished' to 'none'. + expect(UrlStateSelectors.getDataSource(getState())).toEqual('none'); + + // No profile should be loaded. + expect(ProfileViewSelectors.getProfileOrNull(getState())).toEqual(null); + }); }); });