added local play by pressing cancel on the JS prompt
removed the uncessesary null check in the validate_name
This commit is contained in:
+5
-14
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user