diff --git a/src/pages/mod/index.tsx b/src/pages/mod/index.tsx index 0e93253..e01dca9 100644 --- a/src/pages/mod/index.tsx +++ b/src/pages/mod/index.tsx @@ -29,7 +29,9 @@ import { checkUrlForFile, copyTextToClipboard, downloadFile, - getFilenameFromUrl + getFilenameFromUrl, + isReachable, + isValidUrl } from '../../utils' import { Comments } from '../../components/comment' import { PublishDetails } from 'components/Internal/PublishDetails' @@ -615,11 +617,25 @@ const Download = ({ }: DownloadUrl) => { const [showAuthDetails, setShowAuthDetails] = useState(false) const [showNotice, setShowNotice] = useState(false) - const showScanNotice = !malwareScanLink + const [showScanNotice, setShowCanNotice] = useState(false) useDidMount(async () => { const isFile = await checkUrlForFile(url) setShowNotice(!isFile) + + // Check the malware scan url + // if it's valid URL + // if it's reachable + // if it contains sha256 + const regex = /\b[a-fA-F0-9]{64}\b/ + setShowCanNotice( + !( + malwareScanLink && + isValidUrl(malwareScanLink) && + (await isReachable(malwareScanLink)) && + regex.test(url) + ) + ) }) const handleDownload = () => {