fix: Error uploading fallback avatar when name contains characters that need to be escaped (#2387)

* Todo -> Task to match new langauge elsewhere

* fix: Correctly escape characters in Tiley url

* Move encoding to avatars logic, add test
This commit is contained in:
Tom Moor
2021-07-28 14:45:47 -04:00
committed by GitHub
parent 2a473bf7b4
commit e53bb8bfbc
2 changed files with 13 additions and 1 deletions

View File

@ -29,6 +29,8 @@ export async function generateAvatarUrl({
}
}
const tileyUrl = `${DEFAULT_AVATAR_HOST}/avatar/${hashedId}/${name[0]}.png`;
const tileyUrl = `${DEFAULT_AVATAR_HOST}/avatar/${hashedId}/${encodeURIComponent(
name[0]
)}.png`;
return cbUrl && cbResponse && cbResponse.status === 200 ? cbUrl : tileyUrl;
}