next-routes icon indicating copy to clipboard operation
next-routes copied to clipboard

Expectation on Routing Not Met

Open pkellner opened this issue 5 years ago • 0 comments

I have a routes file as below and am getting an error saying "ccYear expected to be a string". Maybe I'm not following the implementation, but what I expect is that I have several routes.add(...), and whatever I put in the 2nd parameter will be matched to see if the incoming routes matches the parameter with a regex compare. Once one is found (in order of added), the route is executed to the /pages/{third parameter}.

I have two issues. First, is if I only have one route

routes.add("r1","/session/:ccYear([0-9][0-9][0-9][0-9])/sort/title","sessionPageByTitle");

I get the error "ccYear expted to be a string. My URL is /session/2018/sort/title

The second issue, is when I have multipe route add, I don't get the first route matched processed. I either get 404 or this ccYear error. Here is the order of the adds

routes.add(
    "sessionWithYearSlug",
    "/session/:ccYear([0-9][0-9][0-9][0-9])/:sessionSlug",
    "sessionPageDetail"
);

routes.add(
    "sessionWithYearSortTimeRoute",
    "/session/:ccYear([0-9][0-9][0-9][0-9])/sort/time",
    "sessionPageByTime"
);

routes.add(
    "sessionWithYearSortTitleRoute",
    "/session/:ccYear([0-9][0-9][0-9][0-9])/sort/title",
    "sessionPageByTitle"
);

routes.add(
    "sessionWithJustYearRoute",
    "/session/:ccYear([0-9][0-9][0-9][0-9])",
    "sessionPageByTitle"
);

routes.add(
    "sessionWithJustYearRoute",
    "/session/:ccYear([0-9][0-9][0-9][0-9])",
    "sessionPageByTitle"
);

routes.add("sessionWithNoParamsRoute", "/session", "sessionPageByTime");

routes.add(
    "sessionSortByTitleRoute",
    "/session/:ccYear/sort/title",
    "sessionPageByTitle"
);
routes.add(
    "sessionSortByTimeRoute",
    "/session/:ccYear/sort/time",
    "sessionPageByTime"
);


pkellner avatar Oct 09 '18 15:10 pkellner