Skip to content

Commit

Permalink
fix: better youtube urls
Browse files Browse the repository at this point in the history
  • Loading branch information
zkrising committed May 13, 2024
1 parent 362a8df commit 8fef72a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
5 changes: 1 addition & 4 deletions client/src/components/user/UserHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,7 @@ export function UserHeaderBody({ reqUser }: { reqUser: UserDocument }) {
/>
<ConditionalSocialMediaRender href="https://twitch.tv/" mode="twitch" />
<ConditionalSocialMediaRender href="https://twitter.com/" mode="twitter" />
<ConditionalSocialMediaRender
href="https://youtube.com/channel/"
mode="youtube"
/>
<ConditionalSocialMediaRender href="https://youtube.com/@" mode="youtube" />
<li>
<Muted>UserID: {reqUser.id}</Muted>
</li>
Expand Down
10 changes: 10 additions & 0 deletions server/src/server/router/api/v1/users/_userID/router.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,16 @@ t.test("PATCH /api/v1/users/:userID", async (t) => {

t.equal(dbUser2?.socialMedia.youtube, "zkldi");

const res3 = await mockApi.patch("/api/v1/users/1").set("Cookie", cookie).send({
youtube: "https://youtube.com/@zkldi",
});

t.equal(res3.body.body.socialMedia.youtube, "zkldi");

const dbUser3 = await db.users.findOne({ id: 1 });

t.equal(dbUser3?.socialMedia.youtube, "zkldi");

t.end();
});

Expand Down
3 changes: 2 additions & 1 deletion server/src/server/router/api/v1/users/_userID/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,10 @@ router.patch(
}

if (IsNonEmptyString(body.youtube)) {
// youtube has two user urls lol
// youtube has THREE user urls lol
body.youtube = StripUrl("youtube.com/user/", body.youtube);
body.youtube = StripUrl("youtube.com/channel/", body.youtube);
body.youtube = StripUrl("youtube.com/@", body.youtube);
}

if (IsNonEmptyString(body.twitch)) {
Expand Down

0 comments on commit 8fef72a

Please sign in to comment.