From 95859f0638cc3083e762040c2bc26a07471fea9c Mon Sep 17 00:00:00 2001 From: TestingPlant <44930139+TestingPlant@users.noreply.github.com> Date: Tue, 9 Apr 2024 17:43:23 -0500 Subject: [PATCH] fix: don't panic when username is less than 10 chars --- crates/server/src/net.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/server/src/net.rs b/crates/server/src/net.rs index 10112d2e..b5e5fd6a 100644 --- a/crates/server/src/net.rs +++ b/crates/server/src/net.rs @@ -386,7 +386,8 @@ impl Io { let username = username.0; // trim username to 10 chars - let username = username[..10].to_owned(); + let username_len = std::cmp::min(username.len(), 10); + let username = &username[..username_len]; // add 2 random chars to the end of the username let username = format!(