Skip to content

Commit 9b728ae

Browse files
author
Samuel Jenks
committed
fix: index out of bounds
1 parent cc6a47f commit 9b728ae

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

‎src/main.rs‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,15 @@ async fn handle_request(req: Request<Body>) -> Result<Response<Body>, Infallible
5858
let slice = current.as_str();
5959

6060
if slice == "--filename" || slice == "-f" {
61-
html_file = args[index + 1].as_str();
61+
let potential_next = args.get(index + 1);
62+
63+
match potential_next {
64+
Some(next) => html_file = next, //use this filename
65+
None => {
66+
println!("Missing filename argument.");
67+
break;
68+
}
69+
}
6270
}
6371
}
6472
println!("Serving HTML file: {}", html_file);

0 commit comments

Comments
 (0)