mirror of
https://github.com/tiennm99/open-domains.git
synced 2026-10-14 10:18:58 +00:00
chore: more validation
This commit is contained in:
1 parent
e6e98cf28d
commit
f6cc7d5f86
1 file changed
+23
@@ -80,6 +80,29 @@ t("All files should have the required fields", (t) => {
|
||||
});
|
||||
});
|
||||
|
||||
t("All files should have lowercase subdomain/domain and match filename", (t) => {
|
||||
const files = fs.readdirSync(domainsPath).filter(file => {
|
||||
const filePath = path.join(domainsPath, file);
|
||||
return file.endsWith(".json") && fs.lstatSync(filePath).isFile();
|
||||
});
|
||||
|
||||
files.forEach(file => {
|
||||
const filePath = path.join(domainsPath, file);
|
||||
const data = fs.readJsonSync(filePath);
|
||||
|
||||
const { subdomain, domain } = data;
|
||||
|
||||
t.truthy(subdomain, `${file}: Missing subdomain field`);
|
||||
t.truthy(domain, `${file}: Missing domain field`);
|
||||
|
||||
t.is(subdomain, subdomain.toLowerCase(), `${file}: 'subdomain' must be lowercase`);
|
||||
t.is(domain, domain.toLowerCase(), `${file}: 'domain' must be lowercase`);
|
||||
|
||||
const expectedFileName = `${subdomain}.${domain}.json`;
|
||||
t.is(file, expectedFileName, `${file}: Filename does not match subdomain and domain`);
|
||||
});
|
||||
});
|
||||
|
||||
t("All files should have valid optional owner fields", (t) => {
|
||||
const files = fs.readdirSync(domainsPath).filter(file => {
|
||||
const filePath = path.join(domainsPath, file);
|
||||
|
||||
Reference in new issue
Block a user