From 219f4086aa2e2bca5c788b9a73c32c2913c2de0b Mon Sep 17 00:00:00 2001 From: deadvey Date: Tue, 2 Jun 2026 12:14:14 +0100 Subject: [PATCH] added local play by pressing cancel on the JS prompt removed the uncessesary null check in the validate_name --- .gitignore | 1 + src/main.rs | 19 ++++-------- static/index.html | 56 +++++++++++++++++++++++++---------- static/leaderboard/index.html | 3 +- 4 files changed, 48 insertions(+), 31 deletions(-) diff --git a/.gitignore b/.gitignore index 71788d4..34c6aa8 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ hiscores.json loscores.json pingscores.json .* +address.js diff --git a/src/main.rs b/src/main.rs index 47bf080..1485a6a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -444,21 +444,12 @@ async fn handle_socket fn validate_name(input: &str) -> &str { let input = input.trim(); - if input == "null" + // Allow only letters, numbers, _ and - + let re = Regex::new(r"^[a-zA-Z0-9_-]+$").unwrap(); + // Length check + if input.is_empty() || input.len() > 32 || !re.is_match(input) { return "anon"; } - // Length check - if input.is_empty() || input.len() > 32 { - return "anon"; - } - - // Allow only letters, numbers, _ and - - let re = Regex::new(r"^[a-zA-Z0-9_-]+$").unwrap(); - - if re.is_match(input) { - input - } else { - "anon" - } + input } diff --git a/static/index.html b/static/index.html index 0c43ed2..4ed6285 100644 --- a/static/index.html +++ b/static/index.html @@ -9,16 +9,26 @@
+