lib: Make pref_strings lowercase

Signed-off-by: Ben Aaron Goldberg <ben@benaaron.dev>
This commit is contained in:
Ben Aaron Goldberg 2021-10-24 05:41:06 -04:00
parent 680bbd5b2d
commit 63e4f2b8fc
1 changed files with 2 additions and 2 deletions

View File

@ -78,7 +78,7 @@ pub trait Preference {
/// This is the primary method of creating a `Preference` object from a prefstring. The
/// default implementation calls the underlying [`Preference::from_prefstring_bytes()`] method.
fn from_prefstring(prefstring: &str) -> Result<Self, ParseError> where Self: Sized {
BASE32_NOPAD.decode(prefstring.as_ref())
BASE32_NOPAD.decode(prefstring.to_uppercase().as_bytes())
.map_err(ParseError::Base32Error)
.and_then(|ps| Self::from_prefstring_bytes(&ps))
}
@ -88,7 +88,7 @@ pub trait Preference {
/// This is the primary method of creating a prefstring from a `Preference` object. The
/// default implementation calls the underlying [`Preference::into_prefstring_bytes()`] method.
fn as_prefstring(&self) -> String {
BASE32_NOPAD.encode(&self.as_prefstring_bytes())
BASE32_NOPAD.encode(&self.as_prefstring_bytes()).to_lowercase()
}
/// Select a pronoun for today using this Preference's WeightedTable.