diff --git a/packages/perseus/src/build.rs b/packages/perseus/src/build.rs index 944e8e16b0..555ce613bf 100644 --- a/packages/perseus/src/build.rs +++ b/packages/perseus/src/build.rs @@ -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(), }; diff --git a/packages/perseus/src/router/app_route.rs b/packages/perseus/src/router/app_route.rs index a9499d281e..cae2e2d33c 100644 --- a/packages/perseus/src/router/app_route.rs +++ b/packages/perseus/src/router/app_route.rs @@ -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::>(); // 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, diff --git a/packages/perseus/src/router/get_subsequent_view.rs b/packages/perseus/src/router/get_subsequent_view.rs index 1bda633d7e..c596c11e53 100644 --- a/packages/perseus/src/router/get_subsequent_view.rs +++ b/packages/perseus/src/router/get_subsequent_view.rs @@ -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),