Update checkRecords.js

This commit is contained in:
William Harrison
2022-12-29 18:20:12 +08:00
committed by GitHub
parent 159f9b7f80
commit 48ed3dd0af
+10 -2
View File
@@ -2,17 +2,25 @@ const { checkIfValidIP, checkIfValidFQDN, checkInvalidDomain } = require('./uti
function checkRecords(data) {
const recordType = Object.keys(data.target)[0];
// Check if the domain is invalid
if (checkInvalidDomain(data.target[recordType].name) === true) return false;
// Check A record
if (recordType.toLowerCase() === 'a') {
return checkIfValidIP(data.target[recordType].value);
}
// Check CNAME record
if (recordType.toLowerCase() === 'cname') {
return checkIfValidFQDN(data.target[recordType].value);
}
// Check if record name matches file name
if (recordType.toLowerCase() === 'a' || recordType.toLowerCase() === 'cname') {
if (data.target[recordType].name != /* Put file name value here */) return false;
}
return false;
}