Commit 5b708c72 authored by devjiwonchoi's avatar devjiwonchoi

fix PageType

parent 4436f5ac
......@@ -249,9 +249,11 @@ impl AppPage {
if let Some(last) = app_page.0.last_mut()
&& let PageSegment::Static(last_name) = &*last
{
if last_name.starts_with("page.") {
// We normalize both file-style leaves (`page.tsx`/`route.ts`) and
// debug-build-path leaves (`page`/`route`) to the same PageType.
if last_name == "page" || last_name.starts_with("page.") {
*last = PageSegment::PageType(PageType::Page);
} else if last_name.starts_with("route") {
} else if last_name == "route" || last_name.starts_with("route.") {
*last = PageSegment::PageType(PageType::Route);
}
// can also be metadata (and be neither Page nor Route)
......@@ -558,6 +560,17 @@ mod test {
])
);
assert_eq!(
AppPage::parse("(group)/foo/@par/bar/page").unwrap(),
AppPage(vec![
PageSegment::Group("group".into()),
PageSegment::Static("foo".into()),
PageSegment::Parallel("par".into()),
PageSegment::Static("bar".into()),
PageSegment::PageType(PageType::Page),
])
);
assert_eq!(
AppPage::parse("(group)/foo/@par/bar/route.tsx").unwrap(),
AppPage(vec![
......@@ -569,6 +582,17 @@ mod test {
])
);
assert_eq!(
AppPage::parse("(group)/foo/@par/bar/route").unwrap(),
AppPage(vec![
PageSegment::Group("group".into()),
PageSegment::Static("foo".into()),
PageSegment::Parallel("par".into()),
PageSegment::Static("bar".into()),
PageSegment::PageType(PageType::Route),
])
);
assert_eq!(
AppPage::parse("foo/sitemap").unwrap(),
AppPage(vec![
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment