Tighten Docker hostname regex for monitor URL validation

This commit is contained in:
Yasir Rafique committed 2025-07-18 11:58:27 +01:00
1 parent b823f0f7db
commit 8ffd9a5e2a
2 files changed
+2 -2

No files matched your search

+1 -1
View File
@@ -130,7 +130,7 @@ const monitorValidation = joi.object({
.custom((value, helpers) => {
const noProtocol = value.replace(/^(https?:\/\/)/, "");
if (/^[a-zA-Z0-9.-]+(:\d{1,5})?$/.test(noProtocol)) {
if (/^[a-zA-Z0-9]([a-zA-Z0-9.-]*[a-zA-Z0-9])?(:\d{1,5})?$/.test(noProtocol)) {
return value;
}
+1 -1
View File
@@ -174,7 +174,7 @@ const createMonitorBodyValidation = joi.object({
.custom((value, helpers) => {
const noProtocol = value.replace(/^(https?:\/\/)/, "");
if (/^[a-zA-Z0-9.-]+(:\d{1,5})?$/.test(noProtocol)) {
if (/^[a-zA-Z0-9]([a-zA-Z0-9.-]*[a-zA-Z0-9])?(:\d{1,5})?$/.test(noProtocol)) {
return value;
}