Skip to content

Commit

Permalink
fix: bug with client-side routing no longer working due to different …
Browse files Browse the repository at this point in the history
…origin (#1899)
  • Loading branch information
gbj authored Oct 16, 2023
1 parent 72ad1d7 commit ad208ec
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions router/src/history/url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,17 @@ impl TryFrom<&str> for Url {
type Error = String;

fn try_from(url: &str) -> Result<Self, Self::Error> {
let url =
web_sys::Url::new(&format!("http://leptos{url}")).map_js_error()?;
let url = web_sys::Url::new_with_base(
&if url.starts_with("//") {
let origin =
leptos::window().location().origin().unwrap_or_default();
format!("{origin}{url}")
} else {
url.to_string()
},
"http://leptos",
)
.map_js_error()?;
Ok(Self {
origin: url.origin(),
pathname: url.pathname(),
Expand Down

0 comments on commit ad208ec

Please sign in to comment.