Encode causality tokens using URL-safe b64
this should fix the pollitem test where the ct was passed in the url
This commit is contained in:
parent
7362618b97
commit
fdbed3f1e8
1 changed files with 3 additions and 2 deletions
|
@ -42,11 +42,12 @@ impl CausalContext {
|
|||
bytes.extend(u64::to_be_bytes(i));
|
||||
}
|
||||
|
||||
base64::encode(bytes)
|
||||
base64::encode_config(bytes, base64::URL_SAFE_NO_PAD)
|
||||
}
|
||||
/// Parse from base64-encoded binary representation
|
||||
pub fn parse(s: &str) -> Result<Self, Error> {
|
||||
let bytes = base64::decode(s).ok_or_message("Invalid causality token (bad base64)")?;
|
||||
let bytes = base64::decode_config(s, base64::URL_SAFE_NO_PAD)
|
||||
.ok_or_message("Invalid causality token (bad base64)")?;
|
||||
if bytes.len() % 16 != 8 || bytes.len() < 8 {
|
||||
return Err(Error::Message(
|
||||
"Invalid causality token (bad length)".into(),
|
||||
|
|
Loading…
Reference in a new issue