fix(pending post page): prevent crash and ensure redirect to "not found" on invalid URL

This commit is contained in:
plebeius
2025-06-12 17:51:08 +02:00
parent 3f2a8a3790
commit 7374465c4f
2 changed files with 2 additions and 5 deletions
+1 -1
View File
@@ -63,7 +63,7 @@ const BoardHeader = () => {
? shortAddress.endsWith('.eth') || shortAddress.endsWith('.sol') ? shortAddress.endsWith('.eth') || shortAddress.endsWith('.sol')
? shortAddress.slice(0, -4) ? shortAddress.slice(0, -4)
: shortAddress : shortAddress
: Plebbit.getShortAddress(subplebbitAddress))} : subplebbitAddress && Plebbit.getShortAddress(subplebbitAddress))}
{(isOffline || isOnlineStatusLoading) && !isInAllView && !isInSubscriptionsView && !isInModView && ( {(isOffline || isOnlineStatusLoading) && !isInAllView && !isInSubscriptionsView && !isInModView && (
<span className={styles.offlineIconWrapper}> <span className={styles.offlineIconWrapper}>
<Tooltip content={offlineTitle}> <Tooltip content={offlineTitle}>
+1 -4
View File
@@ -14,13 +14,10 @@ const PendingPost = () => {
const isValidAccountCommentIndex = const isValidAccountCommentIndex =
!accountCommentIndex || !accountCommentIndex ||
// Check if it's a valid positive integer
(!isNaN(parseInt(accountCommentIndex)) && (!isNaN(parseInt(accountCommentIndex)) &&
parseInt(accountCommentIndex) >= 0 && parseInt(accountCommentIndex) >= 0 &&
Number.isInteger(parseFloat(accountCommentIndex)) && Number.isInteger(parseFloat(accountCommentIndex)) &&
// Allow index to be at most 1 position beyond the current length (accountComments?.length === 0 || parseInt(accountCommentIndex) < accountComments.length));
// This handles the case where a new post is being created
(accountComments?.length === 0 || parseInt(accountCommentIndex) <= accountComments.length));
useEffect(() => { useEffect(() => {
if (!isValidAccountCommentIndex) { if (!isValidAccountCommentIndex) {