Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/actions/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
8 changes: 4 additions & 4 deletions src/actions/receive-profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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:
Expand Down
14 changes: 14 additions & 0 deletions src/test/store/receive-profile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});

Expand Down