We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 72ad1d7 commit ad208ecCopy full SHA for ad208ec
router/src/history/url.rs
@@ -36,8 +36,17 @@ impl TryFrom<&str> for Url {
36
type Error = String;
37
38
fn try_from(url: &str) -> Result<Self, Self::Error> {
39
- let url =
40
- web_sys::Url::new(&format!("http://leptos{url}")).map_js_error()?;
+ let url = web_sys::Url::new_with_base(
+ &if url.starts_with("//") {
41
+ let origin =
42
+ leptos::window().location().origin().unwrap_or_default();
43
+ format!("{origin}{url}")
44
+ } else {
45
+ url.to_string()
46
+ },
47
+ "http://leptos",
48
+ )
49
+ .map_js_error()?;
50
Ok(Self {
51
origin: url.origin(),
52
pathname: url.pathname(),
0 commit comments