Skip to content

Commit

Permalink
fix: do not unescape / and other route characters when following a li…
Browse files Browse the repository at this point in the history
  • Loading branch information
gbj authored Jun 28, 2024
1 parent 551f9b0 commit ff0c825
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion router/src/components/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ impl RouterContextInner {
}

let url = Url::try_from(href.as_str()).unwrap();
let path_name = unescape(&url.pathname);
let path_name = crate::history::unescape_minimal(&url.pathname);

// let browser handle this event if it leaves our domain
// or our base path
Expand Down
5 changes: 5 additions & 0 deletions router/src/history/url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ pub fn unescape(s: &str) -> String {
js_sys::decode_uri_component(s).unwrap().into()
}

#[cfg(not(feature = "ssr"))]
pub fn unescape_minimal(s: &str) -> String {
js_sys::decode_uri(s).unwrap().into()
}

#[cfg(feature = "ssr")]
pub fn escape(s: &str) -> String {
percent_encoding::utf8_percent_encode(s, percent_encoding::NON_ALPHANUMERIC)
Expand Down

0 comments on commit ff0c825

Please sign in to comment.