mirror of
https://github.com/tiennm99/is-a-good-dev.git
synced 2026-10-13 02:14:43 +00:00
Add type checking.
This commit is contained in:
1 parent
70c86de305
commit
59c9cd0329
1 file changed
+6
-4
@@ -1,14 +1,15 @@
|
||||
const { checkIfValidIP, checkIfValidFQDN, checkInvalidDomain } = require('./utils.js');
|
||||
const { checkIfValidIP, checkIfValidFQDN, checkInvalidDomain, isString } = require('./utils.js');
|
||||
|
||||
function checkRecords(data) {
|
||||
const recordType = Object.keys(data.target)[0];
|
||||
|
||||
const value = data.target[recordType].value;
|
||||
// Check if the domain is invalid
|
||||
if (checkInvalidDomain(data.target[recordType].name) === true) return false;
|
||||
|
||||
// Check A record
|
||||
if (recordType.toLowerCase() === 'a') {
|
||||
for (const record of data.target[recordType].value) {
|
||||
if (!Array.isArray(value)) return false;
|
||||
for (const record of value) {
|
||||
if (checkIfValidIP(record) == false) return false;
|
||||
}
|
||||
return true;
|
||||
@@ -16,7 +17,8 @@ function checkRecords(data) {
|
||||
|
||||
// Check CNAME record
|
||||
if (recordType.toLowerCase() === 'cname') {
|
||||
return checkIfValidFQDN(data.target[recordType].value);
|
||||
if (!isString(value)) return false;
|
||||
return checkIfValidFQDN(value);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
Reference in new issue
Block a user