1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 19:27:24 +08:00

Merge pull request #28260 from bdach/discord-rpc-i-swear-to-god

Fix unnecessary padding of empty strings for discord RPC purposes
This commit is contained in:
Dan Balasescu 2024-05-20 20:36:07 +09:00 committed by GitHub
commit 2aa9328830
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -273,7 +273,11 @@ namespace osu.Desktop
private static string clampLength(string str) private static string clampLength(string str)
{ {
// For whatever reason, discord decides that strings shorter than 2 characters cannot possibly be valid input, because... reasons? // Empty strings are fine to discord even though single-character strings are not. Make it make sense.
if (string.IsNullOrEmpty(str))
return str;
// As above, discord decides that *non-empty* strings shorter than 2 characters cannot possibly be valid input, because... reasons?
// And yes, that is two *characters*, or *codepoints*, not *bytes* as further down below (as determined by empirical testing). // And yes, that is two *characters*, or *codepoints*, not *bytes* as further down below (as determined by empirical testing).
// That seems very questionable, and isn't even documented anywhere. So to *make it* accept such valid input, // That seems very questionable, and isn't even documented anywhere. So to *make it* accept such valid input,
// just tack on enough of U+200B ZERO WIDTH SPACEs at the end. // just tack on enough of U+200B ZERO WIDTH SPACEs at the end.