diff --git a/leptos/Cargo.toml b/leptos/Cargo.toml index 77213d511e..30be04993e 100644 --- a/leptos/Cargo.toml +++ b/leptos/Cargo.toml @@ -66,6 +66,7 @@ miniserde = ["leptos_reactive/miniserde"] rkyv = ["leptos_reactive/rkyv"] tracing = ["leptos_macro/tracing"] nonce = ["leptos_dom/nonce"] +spin = ["leptos_reactive/spin"] experimental-islands = [ "leptos_dom/experimental-islands", "leptos_macro/experimental-islands", diff --git a/leptos_reactive/Cargo.toml b/leptos_reactive/Cargo.toml index 798534517d..8f3617017c 100644 --- a/leptos_reactive/Cargo.toml +++ b/leptos_reactive/Cargo.toml @@ -26,6 +26,7 @@ bytecheck = { version = "0.7", features = [ rustc-hash = "1" serde-wasm-bindgen = "0.5" serde_json = "1" +spin-sdk = { git = "https://github.com/fermyon/spin", tag = "v2.0.1", optional = true } base64 = "0.21" thiserror = "1" tokio = { version = "1", features = [ @@ -76,6 +77,7 @@ serde-lite = ["dep:serde-lite"] miniserde = ["dep:miniserde"] rkyv = ["dep:rkyv", "dep:bytecheck"] experimental-islands = [] +spin = ["ssr", "dep:spin-sdk", "leptos/spin"] [package.metadata.cargo-all-features] denylist = ["nightly"] diff --git a/leptos_reactive/src/spawn.rs b/leptos_reactive/src/spawn.rs index aa60a32c1d..4f0bc596ca 100644 --- a/leptos_reactive/src/spawn.rs +++ b/leptos_reactive/src/spawn.rs @@ -75,7 +75,10 @@ where F: Future + 'static, { cfg_if! { - if #[cfg(target_arch = "wasm32")] { + if #[cfg(all(target_arch = "wasm32", target_os = "wasi", feature = "ssr", feature = "spin"))] { + spin_sdk::http::run(fut) + } + else if #[cfg(target_arch = "wasm32")] { wasm_bindgen_futures::spawn_local(fut) } else if #[cfg(any(test, doctest))] { diff --git a/router/src/history/mod.rs b/router/src/history/mod.rs index a55fe294c4..4fdfde07e7 100644 --- a/router/src/history/mod.rs +++ b/router/src/history/mod.rs @@ -39,8 +39,8 @@ impl BrowserIntegration { let loc = leptos_dom::helpers::location(); LocationChange { value: loc.pathname().unwrap_or_default() - + &loc.search().unwrap_or_default() - + &loc.hash().unwrap_or_default(), + + loc.search().unwrap_or_default().as_str() + + loc.hash().unwrap_or_default().as_str(), replace: true, scroll: true, state: State(None), diff --git a/router/src/matching/resolve_path.rs b/router/src/matching/resolve_path.rs index e774cda21a..32236d4c74 100644 --- a/router/src/matching/resolve_path.rs +++ b/router/src/matching/resolve_path.rs @@ -62,7 +62,7 @@ fn normalize(path: &str, omit_slash: bool) -> Cow<'_, str> { #[doc(hidden)] pub fn join_paths<'a>(from: &'a str, to: &'a str) -> String { let from = remove_wildcard(&normalize(from, false)); - from + &normalize(to, false) + from + normalize(to, false).as_ref() } fn begins_with_query_or_hash(text: &str) -> bool {