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', () => {
|
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: true, singleUserModeProfile: '@alex' }).redirectRootNoLogin).toBe('/@alex');
|
||||||
expect(normalizeSoapboxConfig({ singleUserMode: false, singleUserModeProfile: 'alex' }).redirectRootNoLogin).toBe('');
|
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`. */
|
/** Single user mode is now managed by `redirectRootNoLogin`. */
|
||||||
const upgradeSingleUserMode = (soapboxConfig: SoapboxConfigMap): SoapboxConfigMap => {
|
const upgradeSingleUserMode = (soapboxConfig: SoapboxConfigMap): SoapboxConfigMap => {
|
||||||
const singleUserMode = soapboxConfig.get('singleUserMode');
|
const singleUserMode = soapboxConfig.get('singleUserMode') as boolean | undefined;
|
||||||
const singleUserModeProfile = soapboxConfig.get('singleUserModeProfile');
|
const singleUserModeProfile = soapboxConfig.get('singleUserModeProfile') as string | undefined;
|
||||||
const redirectRootNoLogin = soapboxConfig.get('redirectRootNoLogin');
|
const redirectRootNoLogin = soapboxConfig.get('redirectRootNoLogin') as string | undefined;
|
||||||
|
|
||||||
if (!redirectRootNoLogin && singleUserMode && singleUserModeProfile) {
|
if (!redirectRootNoLogin && singleUserMode && singleUserModeProfile) {
|
||||||
return soapboxConfig
|
return soapboxConfig
|
||||||
.set('redirectRootNoLogin', `/@${singleUserModeProfile}`)
|
.set('redirectRootNoLogin', `/@${singleUserModeProfile.replaceAll('@', '')}`)
|
||||||
.deleteAll(['singleUserMode', 'singleUserModeProfile']);
|
.deleteAll(['singleUserMode', 'singleUserModeProfile']);
|
||||||
} else {
|
} else {
|
||||||
return soapboxConfig
|
return soapboxConfig
|
||||||
|
|
Loading…
Reference in a new issue