fix(not found): check if subplebbitAddress is valid before displaying 'back to' buttton

This commit is contained in:
plebeius.eth
2024-05-17 16:29:39 +02:00
parent 970c726720
commit f7ce6890ec
+2 -1
View File
@@ -19,6 +19,7 @@ const NotFoundImage = () => {
const NotFound = () => { const NotFound = () => {
const { subplebbitAddress } = useParams(); const { subplebbitAddress } = useParams();
const isValidSubplebbitAddress = !subplebbitAddress || subplebbitAddress.includes('.') || /^12D3K[a-zA-Z0-9]{44}$/.test(subplebbitAddress);
const [theme, setTheme] = useTheme(); const [theme, setTheme] = useTheme();
const previousThemeRef = useRef(theme); const previousThemeRef = useRef(theme);
@@ -47,7 +48,7 @@ const NotFound = () => {
</div> </div>
<div className={styles.boxContent}> <div className={styles.boxContent}>
<NotFoundImage /> <NotFoundImage />
{subplebbitAddress && ( {subplebbitAddress && isValidSubplebbitAddress && (
<> <>
<br /> <br />
<div className={styles.backToBoard}> <div className={styles.backToBoard}>