From 29bf78d09b3380a24a11c70b09f5011f537f5b95 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 13 Jan 2023 18:54:25 -0600 Subject: [PATCH] Correctly normalize singleUserModeProfile if it has an @ --- .../normalizers/soapbox/__tests__/soapbox-config.test.ts | 1 + app/soapbox/normalizers/soapbox/soapbox-config.ts | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/soapbox/normalizers/soapbox/__tests__/soapbox-config.test.ts b/app/soapbox/normalizers/soapbox/__tests__/soapbox-config.test.ts index 5eccab870..6901254f2 100644 --- a/app/soapbox/normalizers/soapbox/__tests__/soapbox-config.test.ts +++ b/app/soapbox/normalizers/soapbox/__tests__/soapbox-config.test.ts @@ -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(''); }); diff --git a/app/soapbox/normalizers/soapbox/soapbox-config.ts b/app/soapbox/normalizers/soapbox/soapbox-config.ts index f2366bdf1..eba76454c 100644 --- a/app/soapbox/normalizers/soapbox/soapbox-config.ts +++ b/app/soapbox/normalizers/soapbox/soapbox-config.ts @@ -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