Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function validIpfsOrIpnsUrl (url, dnsLink) {
// `/ipfs/` is easy to validate, we just check if CID is correct
if (IsIpfs.ipfsUrl(url)) {
return true
}
// `/ipns/` requires multiple stages/branches (can be FQDN with dnslink or CID)
if (validIpnsPath(new URL(url).pathname, dnsLink)) {
return true
}
// everything else is not IPFS-related
return false
}