Correctly normalize singleUserModeProfile if it has an @
This commit is contained in:
parent
d64f4edf61
commit
29bf78d09b
2 changed files with 5 additions and 4 deletions
|
@ -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('');
|
||||
});
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue