This commit is contained in:
William Harrison authored and GitHub committed 2022-12-29 18:07:12 +08:00
1 parent 0992ac4f68
commit 8808f1b60d
1 file changed
+9 -6
+9 -6
View File
@@ -3,19 +3,19 @@ const fs = require('fs');
const core = require('@actions/core');
function getFiles(path) {
//get all files in path, returns arr
// Get all files in path: returns array
const allFiles = fs.readdirSync(path);
return allFiles
}
function getFileExtension(filename) {
//get file ext
// Get file extension
return (/[.]/.exec(filename)) ? /[^.]+$/.exec(filename) : undefined;
}
function stripExt(filename) {
//remove file ext
// Remove file extension
return filename.substr(0, filename.lastIndexOf('.'))
}
@@ -34,17 +34,20 @@ function checkIfValidFQDN(str) {
}
function checkInvalidDomain(str) {
//check invalid domains
// Check invalid domains
if (invalidDomains.includes(str)) {
core.setOutput("recordInfo", "This subdomain has been blocked for register by the is-a-good.dev team.")
core.setOutput("recordInfo", "This subdomain has been blocked.")
return true;
}
//check reserved domains
// Check reserved domains
const files = getFiles("./reserved/").map(file => stripExt(file));
if (files.includes(str)) {
core.setOutput("recordInfo", "This subdomain has been reserved by the is-a-good.dev team.")
return true;
}
return false;
}