diff --git a/src/common.rs b/src/common.rs index dddeaddc2..b5c0c2c8c 100644 --- a/src/common.rs +++ b/src/common.rs @@ -865,7 +865,16 @@ pub fn username() -> String { #[inline] pub fn hostname() -> String { #[cfg(not(any(target_os = "android", target_os = "ios")))] - return whoami::hostname(); + { + #[allow(unused_mut)] + let mut name = whoami::hostname(); + // some time, there is .local, some time not, so remove it for osx + #[cfg(target_os = "macos")] + if name.ends_with(".local") { + name = name.trim_end_matches(".local").to_owned(); + } + name + } #[cfg(any(target_os = "android", target_os = "ios"))] return DEVICE_NAME.lock().unwrap().clone(); }