Sfoglia il codice sorgente

Merge pull request #1406 from DioxusLabs/fix-router-query

Fix web query segments
Jonathan Kelley 1 anno fa
parent
commit
2f1fbf3ca4
1 ha cambiato i file con 4 aggiunte e 8 eliminazioni
  1. 4 8
      packages/router/src/history/web.rs

+ 4 - 8
packages/router/src/history/web.rs

@@ -195,14 +195,10 @@ where
     <R as std::str::FromStr>::Err: std::fmt::Display,
 {
     fn route_from_location(&self) -> R {
-        R::from_str(
-            &self
-                .window
-                .location()
-                .pathname()
-                .unwrap_or_else(|_| String::from("/")),
-        )
-        .unwrap_or_else(|err| panic!("{}", err))
+        let location = self.window.location();
+        let path = location.pathname().unwrap_or_else(|_| "/".into())
+            + &location.search().unwrap_or("".into());
+        R::from_str(&path).unwrap_or_else(|err| panic!("{}", err))
     }
 
     fn full_path(&self, state: &R) -> String {