fix(routing): canonicalize board page 1 routes instead of not-found

Board URLs ending in /1 now redirect to the canonical page-1 path while
preserving search, hash, and settings suffixes.
This commit is contained in:
Tommaso Casaburi
2026-06-27 17:02:51 +07:00
parent 292d3e35a4
commit eacb422f40
2 changed files with 14 additions and 7 deletions
+5 -3
View File
@@ -72,10 +72,12 @@ preloadReplyModal();
const getPostFormRouteKeyPath = (pathname: string) => pathname.replace(/\/settings$/, '').replace(/\/$/, '');
const getPageOneCanonicalPath = (boardIdentifier: string, pathname: string) => `/${boardIdentifier}${pathname.endsWith('/settings') ? '/settings' : ''}`;
const BoardLayout = () => {
const params = useParams();
const { accountCommentIndex, boardIdentifier, pageNumber } = params;
const { pathname, search } = useLocation();
const { pathname, search, hash } = useLocation();
const isMobile = useIsMobile();
const isInAllView = isAllView(pathname);
const isInSubscriptionsView = isSubscriptionsView(pathname, useParams());
@@ -113,8 +115,8 @@ const BoardLayout = () => {
// force rerender of post form when navigating between pages, except when opening settings modal in current view
const key = `${communityAddress}-${getPostFormRouteKeyPath(pathname)}`;
if (pageNumber === '1') {
return <Navigate to='/not-found' replace />;
if (pageNumber === '1' && boardIdentifier) {
return <Navigate to={{ pathname: getPageOneCanonicalPath(boardIdentifier, pathname), search, hash }} replace />;
}
if (isCatalogView(pathname, params) && isFlashBoardRoute(boardIdentifier, directories)) {