fix hostname for mac
This commit is contained in:
parent
c0e5e78d2b
commit
f644053811
@ -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();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user