Skip to content

Commit

Permalink
Limit the function decode_base64 that it shouldn't runnable in non-…
Browse files Browse the repository at this point in the history
…browser environment.
  • Loading branch information
langyo committed Aug 22, 2024
1 parent 768a914 commit 9fdae79
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ use crate::functional::{use_state, Hook, HookContext};
use crate::platform::spawn_local;
use crate::suspense::{Suspension, SuspensionResult};

#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
#[cfg(all(
target_arch = "wasm32",
not(target_os = "wasi"),
not(feature = "not_browser_env")
))]
async fn decode_base64(s: &str) -> Result<Vec<u8>, JsValue> {
use gloo::utils::window;
use js_sys::Uint8Array;
Expand All @@ -34,7 +38,11 @@ async fn decode_base64(s: &str) -> Result<Vec<u8>, JsValue> {
Ok(content_array.to_vec())
}

#[cfg(any(not(target_arch = "wasm32"), target_os = "wasi"))]
#[cfg(any(
not(target_arch = "wasm32"),
target_os = "wasi",
feature = "not_browser_env"
))]
async fn decode_base64(_s: &str) -> Result<Vec<u8>, JsValue> {
unreachable!("this function is not callable under non-wasm targets!");
}
Expand Down

0 comments on commit 9fdae79

Please sign in to comment.