fix(download): scan link detection
All checks were successful
Release to Staging / build_and_release (push) Successful in 58s
All checks were successful
Release to Staging / build_and_release (push) Successful in 58s
Fix #164
This commit is contained in:
parent
02c4cb52b1
commit
18a9744f96
@ -29,7 +29,9 @@ import {
|
|||||||
checkUrlForFile,
|
checkUrlForFile,
|
||||||
copyTextToClipboard,
|
copyTextToClipboard,
|
||||||
downloadFile,
|
downloadFile,
|
||||||
getFilenameFromUrl
|
getFilenameFromUrl,
|
||||||
|
isReachable,
|
||||||
|
isValidUrl
|
||||||
} from '../../utils'
|
} from '../../utils'
|
||||||
import { Comments } from '../../components/comment'
|
import { Comments } from '../../components/comment'
|
||||||
import { PublishDetails } from 'components/Internal/PublishDetails'
|
import { PublishDetails } from 'components/Internal/PublishDetails'
|
||||||
@ -615,11 +617,25 @@ const Download = ({
|
|||||||
}: DownloadUrl) => {
|
}: DownloadUrl) => {
|
||||||
const [showAuthDetails, setShowAuthDetails] = useState(false)
|
const [showAuthDetails, setShowAuthDetails] = useState(false)
|
||||||
const [showNotice, setShowNotice] = useState(false)
|
const [showNotice, setShowNotice] = useState(false)
|
||||||
const showScanNotice = !malwareScanLink
|
const [showScanNotice, setShowCanNotice] = useState(false)
|
||||||
|
|
||||||
useDidMount(async () => {
|
useDidMount(async () => {
|
||||||
const isFile = await checkUrlForFile(url)
|
const isFile = await checkUrlForFile(url)
|
||||||
setShowNotice(!isFile)
|
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 = () => {
|
const handleDownload = () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user