Skip to content

Commit

Permalink
fix panic when BIND_ADDRESS is empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
taoky committed Sep 14, 2023
1 parent 5f6c91a commit 922714a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,17 @@ fn main() {
.with_ansi(enable_color)
.init();

let bind_address = std::env::var("BIND_ADDRESS").ok();
let bind_address = match std::env::var("BIND_ADDRESS").ok() {
Some(s) => {
let s = s.trim();
if s.is_empty() {
None
} else {
Some(s.to_owned())
}
}
None => None,
};

// terminate whole process when a thread panics
let orig_hook = std::panic::take_hook();
Expand Down

0 comments on commit 922714a

Please sign in to comment.