From 1b2fcec0d70f87d16ce7b973c6c15362c1ec58f4 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sat, 14 Jan 2023 19:29:34 -0600 Subject: [PATCH] RedirectRoot: correctly upgrade singleUserModeProfile of a remote user --- .../normalizers/soapbox/__tests__/soapbox-config.test.ts | 1 + app/soapbox/normalizers/soapbox/soapbox-config.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/soapbox/normalizers/soapbox/__tests__/soapbox-config.test.ts b/app/soapbox/normalizers/soapbox/__tests__/soapbox-config.test.ts index 6901254f2..9142a3356 100644 --- a/app/soapbox/normalizers/soapbox/__tests__/soapbox-config.test.ts +++ b/app/soapbox/normalizers/soapbox/__tests__/soapbox-config.test.ts @@ -38,6 +38,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: true, singleUserModeProfile: 'alex@gleasonator.com' }).redirectRootNoLogin).toBe('/@alex@gleasonator.com'); 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 dfac8a777..3b8b2ea91 100644 --- a/app/soapbox/normalizers/soapbox/soapbox-config.ts +++ b/app/soapbox/normalizers/soapbox/soapbox-config.ts @@ -6,6 +6,7 @@ import { } from 'immutable'; import trimStart from 'lodash/trimStart'; +import { normalizeUsername } from 'soapbox/utils/input'; import { toTailwind } from 'soapbox/utils/tailwind'; import { generateAccent } from 'soapbox/utils/theme'; @@ -204,7 +205,7 @@ const upgradeSingleUserMode = (soapboxConfig: SoapboxConfigMap): SoapboxConfigMa if (!redirectRootNoLogin && singleUserMode && singleUserModeProfile) { return soapboxConfig - .set('redirectRootNoLogin', `/@${singleUserModeProfile.replaceAll('@', '')}`) + .set('redirectRootNoLogin', `/@${normalizeUsername(singleUserModeProfile)}`) .deleteAll(['singleUserMode', 'singleUserModeProfile']); } else { return soapboxConfig