Revert "hotfix: remove showurl validation"

This commit is contained in:
Alexander Holliday authored and GitHub committed 2025-05-26 16:30:09 -07:00
1 parent 02ae6f3bd4
commit 2d52ebad40
1 file changed
+65 -64
+65 -64
View File
@@ -23,8 +23,7 @@ const lastnameSchema = joi
.messages({ .messages({
"string.empty": "Surname is required", "string.empty": "Surname is required",
"string.max": "Surname must be less than 50 characters", "string.max": "Surname must be less than 50 characters",
"string.pattern.base": "string.pattern.base": "Surname must contain only letters, spaces, apostrophes, or hyphens"
"Surname must contain only letters, spaces, apostrophes, or hyphens",
}); });
const passwordSchema = joi const passwordSchema = joi
@@ -104,69 +103,70 @@ const credentials = joi.object({
}); });
const monitorValidation = joi.object({ const monitorValidation = joi.object({
url: joi.when("type", { url: joi
is: "docker", .when("type", {
then: joi is: "docker",
.string() then: joi
.trim() .string()
.regex(/^[a-z0-9]{64}$/) .trim()
.messages({ .regex(/^[a-z0-9]{64}$/)
"string.empty": "This field is required.", .messages({
"string.pattern.base": "Please enter a valid 64-character Docker container ID.", "string.empty": "This field is required.",
}), "string.pattern.base": "Please enter a valid 64-character Docker container ID.",
otherwise: joi }),
.string() otherwise: joi
.trim() .string()
.custom((value, helpers) => { .trim()
// Regex from https://gist.github.com/dperini/729294 .custom((value, helpers) => {
var urlRegex = new RegExp( // Regex from https://gist.github.com/dperini/729294
"^" + var urlRegex = new RegExp(
// protocol identifier (optional) "^" +
// short syntax // still required // protocol identifier (optional)
"(?:(?:https?|ftp):\\/\\/)?" + // short syntax // still required
// user:pass BasicAuth (optional) "(?:(?:https?|ftp):\\/\\/)?" +
"(?:" + // user:pass BasicAuth (optional)
// IP address dotted notation octets "(?:" +
// excludes loopback network 0.0.0.0 // IP address dotted notation octets
// excludes reserved space >= 224.0.0.0 // excludes loopback network 0.0.0.0
// excludes network & broadcast addresses // excludes reserved space >= 224.0.0.0
// (first & last IP address of each class) // excludes network & broadcast addresses
"(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])" + // (first & last IP address of each class)
"(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}" + "(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])" +
"(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))" + "(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}" +
"|" + "(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))" +
// host & domain names, may end with dot "|" +
// can be replaced by a shortest alternative // host & domain names, may end with dot
// (?![-_])(?:[-\\w\\u00a1-\\uffff]{0,63}[^-_]\\.)+ // can be replaced by a shortest alternative
"(?:" + // (?![-_])(?:[-\\w\\u00a1-\\uffff]{0,63}[^-_]\\.)+
"(?:" + "(?:" +
"[a-z0-9\\u00a1-\\uffff]" + "(?:" +
"[a-z0-9\\u00a1-\\uffff_-]{0,62}" + "[a-z0-9\\u00a1-\\uffff]" +
")?" + "[a-z0-9\\u00a1-\\uffff_-]{0,62}" +
"[a-z0-9\\u00a1-\\uffff]\\." + ")?" +
")+" + "[a-z0-9\\u00a1-\\uffff]\\." +
// TLD identifier name, may end with dot ")+" +
"(?:[a-z\\u00a1-\\uffff]{2,}\\.?)" + // TLD identifier name, may end with dot
")" + "(?:[a-z\\u00a1-\\uffff]{2,}\\.?)" +
// port number (optional) ")" +
"(?::\\d{2,5})?" + // port number (optional)
// resource path (optional) "(?::\\d{2,5})?" +
"(?:[/?#]\\S*)?" + // resource path (optional)
"$", "(?:[/?#]\\S*)?" +
"i" "$",
); "i"
if (!urlRegex.test(value)) { );
return helpers.error("string.invalidUrl"); if (!urlRegex.test(value)) {
} return helpers.error("string.invalidUrl");
}
return value; return value;
}) })
.messages({ .messages({
"string.empty": "This field is required.", "string.empty": "This field is required.",
"string.uri": "The URL you provided is not valid.", "string.uri": "The URL you provided is not valid.",
"string.invalidUrl": "Please enter a valid URL with optional port", "string.invalidUrl": "Please enter a valid URL with optional port",
}), }),
}), }),
port: joi port: joi
.number() .number()
.integer() .integer()
@@ -277,6 +277,7 @@ const settingsValidation = joi.object({
}), }),
pagespeedApiKey: joi.string().allow("").optional(), pagespeedApiKey: joi.string().allow("").optional(),
language: joi.string().required(), language: joi.string().required(),
showURL: joi.bool().required(),
systemEmailHost: joi.string().allow(""), systemEmailHost: joi.string().allow(""),
systemEmailPort: joi.number().allow(null, ""), systemEmailPort: joi.number().allow(null, ""),
systemEmailAddress: joi.string().allow(""), systemEmailAddress: joi.string().allow(""),