From 9db478bc23159320fb63b0f22999230e3a3c1c19 Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Sun, 5 Jan 2025 13:32:21 +0000 Subject: [PATCH] Change encoding/decoding --- backend/sync_lib/src/lib.rs | 6 +++--- backend/sync_lib/tests/web.rs | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/backend/sync_lib/src/lib.rs b/backend/sync_lib/src/lib.rs index 2f3ec663..d5e6c1d2 100644 --- a/backend/sync_lib/src/lib.rs +++ b/backend/sync_lib/src/lib.rs @@ -10,7 +10,7 @@ //! - `errors`: Contains error types used in this crate. use core::str; -use base64::{engine::general_purpose::STANDARD_NO_PAD, Engine as _}; +use base64::{engine::general_purpose::STANDARD, Engine as _}; use errors::SyncLibError; use wasm_bindgen::prelude::*; @@ -19,12 +19,12 @@ pub mod errors; /// Encode binary data for easy transport over HTTP. Inverse of /// `base64_to_bytes`. #[wasm_bindgen(js_name = bytesToBase64)] -pub fn bytes_to_base64(input: &[u8]) -> String { STANDARD_NO_PAD.encode(input) } +pub fn bytes_to_base64(input: &[u8]) -> String { STANDARD.encode(input) } /// Inverse of `bytes_to_base64`. #[wasm_bindgen(js_name = base64ToBytes)] pub fn base64_to_bytes(input: &str) -> Result, SyncLibError> { - STANDARD_NO_PAD.decode(input).map_err(SyncLibError::from) + STANDARD.decode(input).map_err(SyncLibError::from) } /// Merge two documents with a common parent. Relies on `reconcile::reconcile` diff --git a/backend/sync_lib/tests/web.rs b/backend/sync_lib/tests/web.rs index 642ceaae..3b90fd7b 100644 --- a/backend/sync_lib/tests/web.rs +++ b/backend/sync_lib/tests/web.rs @@ -4,16 +4,18 @@ use insta::assert_debug_snapshot; use sync_lib::*; use wasm_bindgen_test::*; +wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser); + #[wasm_bindgen_test(unsupported = test)] fn test_bytes_to_base64() { let input = b"hello"; - let expected = "aGVsbG8"; + let expected = "aGVsbG8="; assert_eq!(bytes_to_base64(input), expected); } #[wasm_bindgen_test(unsupported = test)] fn test_base64_to_bytes() { - let input = "aGVsbG8"; + let input = "aGVsbG8="; let expected = b"hello".to_vec(); assert_eq!(base64_to_bytes(input).unwrap(), expected); }