Correctly normalize singleUserModeProfile if it has an @

This commit is contained in:
Alex Gleason 2023-01-13 18:54:25 -06:00
parent d64f4edf61
commit 29bf78d09b
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
2 changed files with 5 additions and 4 deletions

View file

@ -37,6 +37,7 @@ describe('normalizeSoapboxConfig()', () => {
it('upgrades singleUserModeProfile to redirectRootNoLogin', () => {
expect(normalizeSoapboxConfig({ singleUserMode: true, singleUserModeProfile: 'alex' }).redirectRootNoLogin).toBe('/@alex');
expect(normalizeSoapboxConfig({ singleUserMode: true, singleUserModeProfile: '@alex' }).redirectRootNoLogin).toBe('/@alex');
expect(normalizeSoapboxConfig({ singleUserMode: false, singleUserModeProfile: 'alex' }).redirectRootNoLogin).toBe('');
});

View file

@ -198,13 +198,13 @@ const normalizeAdsAlgorithm = (soapboxConfig: SoapboxConfigMap): SoapboxConfigMa
/** Single user mode is now managed by `redirectRootNoLogin`. */
const upgradeSingleUserMode = (soapboxConfig: SoapboxConfigMap): SoapboxConfigMap => {
const singleUserMode = soapboxConfig.get('singleUserMode');
const singleUserModeProfile = soapboxConfig.get('singleUserModeProfile');
const redirectRootNoLogin = soapboxConfig.get('redirectRootNoLogin');
const singleUserMode = soapboxConfig.get('singleUserMode') as boolean | undefined;
const singleUserModeProfile = soapboxConfig.get('singleUserModeProfile') as string | undefined;
const redirectRootNoLogin = soapboxConfig.get('redirectRootNoLogin') as string | undefined;
if (!redirectRootNoLogin && singleUserMode && singleUserModeProfile) {
return soapboxConfig
.set('redirectRootNoLogin', `/@${singleUserModeProfile}`)
.set('redirectRootNoLogin', `/@${singleUserModeProfile.replaceAll('@', '')}`)
.deleteAll(['singleUserMode', 'singleUserModeProfile']);
} else {
return soapboxConfig