Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encode Path Parameters in yew-router #3187

Merged
merged 13 commits into from
Jun 21, 2023
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/yew-router-macro/src/routable_derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl Routable {
}

quote! {
Self::#ident { #(#fields),* } => ::std::format!(#right, #(#fields = #fields),*)
Self::#ident { #(#fields),* } => ::std::format!(#right, #(#fields = ::yew_router::__macro::encode_for_url(&::std::format!("{}", #fields))),*)
}
}
Fields::Unnamed(_) => unreachable!(), // already checked
Expand Down
1 change: 1 addition & 0 deletions packages/yew-router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ route-recognizer = "0.3"
serde = "1"
serde_urlencoded = "0.7.1"
tracing = "0.1.37"
urlencoding = "2.1.2"

[dependencies.web-sys]
version = "0.3"
Expand Down
2 changes: 2 additions & 0 deletions packages/yew-router/src/macro_helpers.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
pub use urlencoding::encode as encode_for_url;

use crate::utils::strip_slash_suffix;
use crate::Routable;

Expand Down