Trim \r from command

This commit is contained in:
William Brawner 2022-07-27 21:19:17 -06:00
parent 6e6edfa2bd
commit 938e650592

View file

@ -112,7 +112,7 @@ fn handle_connection(mut stream: TcpStream) {
let mut request: &str = let mut request: &str =
&String::from_utf8(buffer.to_vec()).expect("Failed to convert command to string"); &String::from_utf8(buffer.to_vec()).expect("Failed to convert command to string");
request = request.trim(); request = request.trim();
let trim_chars = [' ', '\n', '\0']; let trim_chars = [' ', '\r', '\n', '\0'];
request = request.trim_matches(&trim_chars[..]); request = request.trim_matches(&trim_chars[..]);
let mut command_iter = request.split_whitespace(); let mut command_iter = request.split_whitespace();
match command_iter.next() { match command_iter.next() {