identifiers-validation: Simplify localpart_is_fully_conforming

This commit is contained in:
Jonas Platte 2022-06-08 11:07:01 +02:00 committed by Jonas Platte
parent 56cf3ce94c
commit 4b756c5887

View File

@ -28,11 +28,8 @@ pub fn localpart_is_fully_conforming(localpart: &str) -> Result<bool, Error> {
// See https://spec.matrix.org/v1.2/appendices/#historical-user-ids
#[cfg(not(feature = "compat"))]
if !is_fully_conforming && localpart.bytes().any(|b| b < 0x21 || b == b':' || b > 0x7E) {
Err(Error::InvalidCharacters)
} else {
Ok(is_fully_conforming)
return Err(Error::InvalidCharacters);
}
#[cfg(feature = "compat")]
Ok(is_fully_conforming)
}