From d96b00c0c6c112ee3df2de491a4bee42300196a0 Mon Sep 17 00:00:00 2001 From: Ashutosh Panda Date: Sun, 4 Oct 2026 07:44:13 +0000 Subject: [PATCH] fix: return user pseuds as an array instead of a joined string getUserProfilePseuds already collects the pseuds into an array and then joins them with ", ", so callers get one string and cannot tell where one pseud ends and the next begins. Return the array instead: User.pseuds is now string[], the zod schema matches, the TODO in getUser is resolved, and the user test expects the array. --- src/users/getters.ts | 3 +-- src/users/index.ts | 1 - tests/user.test.ts | 2 +- types/entities.ts | 2 +- types/zod/generated/schemas.ts | 2 +- 5 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/users/getters.ts b/src/users/getters.ts index 80c0b250..04f8f422 100644 --- a/src/users/getters.ts +++ b/src/users/getters.ts @@ -16,7 +16,6 @@ export const getUserProfileName = ($userProfile: UserProfile) => { return $userProfile(".user.profile .header h2").text().trim(); }; -const PSEUD_SUFFIX = ", "; export const getUserProfilePseuds = ($userProfile: UserProfile) => { const pseuds = $userProfile("dd.pseuds a"); const pseudsArray: string[] = []; @@ -29,7 +28,7 @@ export const getUserProfilePseuds = ($userProfile: UserProfile) => { pseudsArray.push(decodeURI(pseud)); }); } - return pseudsArray.join(PSEUD_SUFFIX); + return pseudsArray; }; //Trim the results to only the date: diff --git a/src/users/index.ts b/src/users/index.ts index d1ac4e7d..0f565f21 100644 --- a/src/users/index.ts +++ b/src/users/index.ts @@ -30,7 +30,6 @@ export const getUser = async ({ return { // We use this because capitalization might be different username: getUserProfileName(profilePage), - // TODO: this should really be an array pseuds: getUserProfilePseuds(profilePage), id: getUserProfileId(profilePage), joined: getUserProfileJoined(profilePage), diff --git a/tests/user.test.ts b/tests/user.test.ts index bb0321b9..11f70ef5 100644 --- a/tests/user.test.ts +++ b/tests/user.test.ts @@ -13,7 +13,7 @@ describe("User/data", () => { username: "astolat", id: 8, url: "https://archiveofourown.org/users/astolat/profile", - pseuds: "astolat, shalott, the lady of shalott", + pseuds: ["astolat", "shalott", "the lady of shalott"], joined: "2008-09-13", } satisfies Partial); }); diff --git a/types/entities.ts b/types/entities.ts index 75b7c9e6..29927a94 100644 --- a/types/entities.ts +++ b/types/entities.ts @@ -74,7 +74,7 @@ export interface TagSearchResultSummary { export interface User { id: ArchiveId; username: string; - pseuds: string; + pseuds: string[]; url: string; shortUrl: string; icon: string; diff --git a/types/zod/generated/schemas.ts b/types/zod/generated/schemas.ts index 03e33a65..a709c45f 100644 --- a/types/zod/generated/schemas.ts +++ b/types/zod/generated/schemas.ts @@ -56,7 +56,7 @@ export const tagSearchResultSummarySchema = z.object({ export const userSchema = z.object({ id: archiveIdSchema, username: z.string(), - pseuds: z.string(), + pseuds: z.array(z.string()), url: z.string(), shortUrl: z.string(), icon: z.string(),