RedirectRoot: correctly upgrade singleUserModeProfile of a remote user

bosnian
Alex Gleason 2023-01-14 19:29:34 -06:00
rodzic 6f40c471c4
commit 1b2fcec0d7
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
2 zmienionych plików z 3 dodań i 1 usunięć

Wyświetl plik

@ -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('');
});

Wyświetl plik

@ -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