mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
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:
+5
-3
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user