fix: allow masked phone author display

This commit is contained in:
kdletters
2026-06-05 00:51:43 +08:00
parent b19a3e4231
commit fdafe8d747
3 changed files with 14 additions and 7 deletions

View File

@@ -237,7 +237,7 @@ test('resolves public work author from display name and public user code before
expect(resolvePlatformWorkAuthorDisplayName(card, null)).toBe('敲木鱼玩家');
});
test('public work author display hides phone masks and public user codes on cards', () => {
test('public work author display keeps phone masks and hides bare public user codes on cards', () => {
const card = mapWoodenFishWorkToPlatformGalleryCard({
publicWorkCode: 'WF-AUTHOR2',
workId: 'wooden-fish-work-author-mask',
@@ -263,8 +263,18 @@ test('public work author display hides phone masks and public user codes on card
displayName: '158****3533',
avatarUrl: null,
}),
).toBe('玩家');
expect(resolvePlatformWorkAuthorDisplayName(card, null)).toBe('玩家');
).toBe('158****3533');
expect(resolvePlatformWorkAuthorDisplayName(card, null)).toBe(
'158****3533 · SY-00000003',
);
const publicCodeOnlyCard = {
...card,
authorDisplayName: 'SY-00000003',
};
expect(resolvePlatformWorkAuthorDisplayName(publicCodeOnlyCard, null)).toBe(
'玩家',
);
});
test('keeps baby object match public card code and template label intact', () => {

View File

@@ -884,9 +884,6 @@ function normalizePlatformPublicAuthorName(value: string | null | undefined) {
}
const compact = normalized.replace(/\s+/gu, '');
if (/^\d+\*+\d+(?:[·.-]?SY-\d+)?$/iu.test(compact)) {
return '';
}
if (/^SY-\d+$/iu.test(compact)) {
return '';
}