mirror of
https://github.com/tiennm99/is-a-dev.git
synced 2026-10-19 10:15:07 +00:00
support new services key
This commit is contained in:
1 parent
d792791995
commit
229d821881
8 files changed
+148
-31
No files matched your search
+13
-11
@@ -11,7 +11,8 @@ const requiredFields = {
|
||||
|
||||
const optionalFields = {
|
||||
proxied: "boolean",
|
||||
redirect_config: "object"
|
||||
redirect_config: "object",
|
||||
services: "object"
|
||||
};
|
||||
|
||||
const requiredOwnerFields = {
|
||||
@@ -27,12 +28,7 @@ const optionalRedirectConfigFields = {
|
||||
redirect_paths: "boolean"
|
||||
};
|
||||
|
||||
const blockedFields = [
|
||||
"domain",
|
||||
"internal",
|
||||
"reserved",
|
||||
"subdomain"
|
||||
];
|
||||
const blockedFields = ["domain", "internal", "reserved", "subdomain"];
|
||||
|
||||
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
||||
const hostnameRegex = /^(?=.{1,253}$)(?:(?:[_a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)\.)+[a-zA-Z]{2,63}$/;
|
||||
@@ -117,10 +113,7 @@ async function validateFileName(t, file) {
|
||||
!internalDomains.some((i) => subdomain.endsWith(`.${i}`)),
|
||||
`${file}: Subdomain name is registered internally`
|
||||
);
|
||||
t.true(
|
||||
!reservedDomains.some((r) => subdomain.endsWith(`.${r}`)),
|
||||
`${file}: Subdomain name is reserved`
|
||||
);
|
||||
t.true(!reservedDomains.some((r) => subdomain.endsWith(`.${r}`)), `${file}: Subdomain name is reserved`);
|
||||
|
||||
const rootSubdomain = subdomain.split(".").pop();
|
||||
t.false(rootSubdomain.startsWith("_"), `${file}: Root subdomains should not start with an underscore`);
|
||||
@@ -157,6 +150,15 @@ async function processFile(file, t) {
|
||||
validateFields(t, data.redirect_config, optionalRedirectConfigFields, file, "redirect_config");
|
||||
}
|
||||
|
||||
if (data.services) {
|
||||
if (data.services.discord) {
|
||||
t.true(
|
||||
Array.isArray(data.services.discord) || typeof data.services.discord === "string",
|
||||
`${file}: Discord service should be an array or string`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
for (const field of blockedFields) {
|
||||
t.true(!data.hasOwnProperty(field), `${file}: Disallowed field: ${field}`);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user