Use username in author media folder names

This commit is contained in:
wolfmanster 2026-08-19 17:24:38 +08:00
parent ae1fb91382
commit bc65ef8630
2 changed files with 5 additions and 4 deletions

View file

@ -24,8 +24,9 @@ describe('media path naming', () => {
expect(folder).not.toMatch(/[<>:"/\\|?*]/);
});
it('builds the author folder from display name and user ID', () => {
expect(buildAuthorFolder({ authorName: 'A/B', userId: '42' }, 'fallback')).toBe('A_B_42');
it('builds the author folder from display name and username', () => {
expect(buildAuthorFolder({ authorName: 'A/B', username: 'animal_kyawa_' }, 'fallback'))
.toBe('A_B@animal_kyawa_');
});
it.each([

View file

@ -33,8 +33,8 @@ export function formatPublishedDate(isoDate: string | undefined): string {
return `${values.year}-${values.month}-${values.day}`;
}
export function buildAuthorFolder(metadata: Pick<PostMetadata, 'authorName' | 'userId'>, fallback: string): string {
return sanitizePathSegment(`${metadata.authorName}_${metadata.userId}`, fallback);
export function buildAuthorFolder(metadata: Pick<PostMetadata, 'authorName' | 'username'>, fallback: string): string {
return sanitizePathSegment(`${metadata.authorName}@${metadata.username}`, fallback);
}
export function buildPostFolder(metadata: Pick<PostMetadata, 'publishedAt' | 'text'> | undefined, tweetId: string): string {