Skip to content

Commit

Permalink
fix: fixed subsequent loads of pages with special characters
Browse files Browse the repository at this point in the history
  • Loading branch information
arctic-hen7 committed Nov 5, 2022
1 parent 18bd1bf commit c112b58
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
6 changes: 0 additions & 6 deletions packages/perseus/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,6 @@ async fn gen_state_for_path(
// save it as a file
let full_path_without_locale = match template.uses_build_paths() {
true => format!("{}/{}", &template_path, path),
// // If we're using build paths on the root template, make sure we don't end up with `index/...`
// true => if template_path == "index" {
// path.to_string()
// } else {
// format!("{}/{}", &template_path, path)
// },
// We don't want to concatenate the name twice if we don't have to
false => template_path.clone(),
};
Expand Down
14 changes: 13 additions & 1 deletion packages/perseus/src/router/app_route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,21 @@ impl<'cx> PerseusRoute<'cx> {
}
impl<'cx> Route for PerseusRoute<'cx> {
fn match_route(&self, path: &[&str]) -> Self {
// Decode the path (we can't do this in `match_route` because of how it's called
// by initial view, and we don't want to double-decode!)
let path = path.join("/");
let path = js_sys::decode_uri_component(&path)
.unwrap()
.as_string()
.unwrap();
let path_segments = path
.split('/')
.filter(|s| !s.is_empty())
.collect::<Vec<&str>>(); // This parsing is identical to the Sycamore router's

let render_ctx = RenderCtx::from_ctx(self.cx.unwrap()); // We know the scope will always exist
let verdict = match_route(
path,
&path_segments,
&render_ctx.render_cfg,
&render_ctx.templates,
&render_ctx.locales,
Expand Down
4 changes: 0 additions & 4 deletions packages/perseus/src/router/get_subsequent_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ pub(crate) async fn get_subsequent_view(
let error_pages = &render_ctx.error_pages;
let pss = &render_ctx.page_state_store;

let path = js_sys::decode_uri_component(&path)
.unwrap()
.as_string()
.unwrap();
let path_with_locale = match locale.as_str() {
"xx-XX" => path.clone(),
locale => format!("{}/{}", locale, &path),
Expand Down

0 comments on commit c112b58

Please sign in to comment.