forge
Explore
Log in

Don't you dare go Hollow

hezarfen_frontend

Clone
★ 0

0 watching0 forksTypeScript5.5 MiBdcf123aBurak Boduroğlu2 months ago674 commits

getUserAvatarUrl.ts9 lines, 574 bytesHistoryRawDownload
1// The avatar endpoint answers with raw image bytes, so it is read through a
2// plain <img src>, not fetch: /api is same-origin, which carries the session
3// cookie on its own. `version` is a cache-buster the caller bumps after an
4// upload or delete — the URL is otherwise identical before and after, and the
5// browser's in-memory image cache would keep serving the old bytes.
6export function getUserAvatarUrl(userId: string, version?: number): string {
7 const bust = version ? `?v=${version}` : "";
8 return `/api/users/${encodeURIComponent(userId)}/avatar${bust}`;
9}