mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(pending post page): prevent crash and ensure redirect to "not found" on invalid URL
This commit is contained in:
@@ -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}>
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user