Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
node: Use `str::trim_end_matches` for stripping '\0' in alias
xphoniex committed 2 years ago
commit ff81b1a6ed0bbc02d2e89520bcddde5cb979e4b4
parent fb63b1c15d72d95b299fad70aa6f4546a5574acb
1 file changed +1 -6
modified radicle-node/src/service/message.rs
@@ -121,12 +121,7 @@ impl NodeAnnouncement {

    /// Get the alias as a UTF-8 string.
    pub fn alias(&self) -> Result<&str, std::str::Utf8Error> {
-
        let length = self
-
            .alias
-
            .iter()
-
            .position(|&b| b == 0)
-
            .unwrap_or(self.alias.len());
-
        str::from_utf8(&self.alias[..length])
+
        Ok(str::from_utf8(&self.alias)?.trim_end_matches(0 as char))
    }
}