@@ -168,7 +168,52 @@ const createMonitorBodyValidation = joi.object({
168
168
name : joi . string ( ) . required ( ) ,
169
169
description : joi . string ( ) . required ( ) ,
170
170
type : joi . string ( ) . required ( ) ,
171
- url : joi . string ( ) . required ( ) ,
171
+ url : joi
172
+ . string ( )
173
+ . required ( )
174
+ . custom ( ( value , helpers ) => {
175
+ const noProtocol = value . replace ( / ^ ( h t t p s ? : \/ \/ ) / , "" ) ;
176
+
177
+ if ( / ^ [ a - z A - Z 0 - 9 . - ] + ( : \d { 1 , 5 } ) ? $ / . test ( noProtocol ) ) {
178
+ return value ;
179
+ }
180
+
181
+ // Existing complex URL validation as fallback
182
+ var urlRegex = new RegExp (
183
+ "^" +
184
+ "(?:(?:https?|ftp):\\/\\/)?" +
185
+ "(?:" +
186
+ "(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])" +
187
+ "(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}" +
188
+ "(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))" +
189
+ "|" +
190
+ "(?:" +
191
+ "(?:" +
192
+ "[a-z0-9\\u00a1-\\uffff]" +
193
+ "[a-z0-9\\u00a1-\\uffff_-]{0,62}" +
194
+ ")?" +
195
+ "[a-z0-9\\u00a1-\\uffff]\\." +
196
+ ")+" +
197
+ "(?:[a-z\\u00a1-\\uffff]{2,}\\.?)" +
198
+ ")" +
199
+ "(?::\\d{2,5})?" +
200
+ "(?:[/?#]\\S*)?" +
201
+ "$" ,
202
+ "i"
203
+ ) ;
204
+
205
+ if ( urlRegex . test ( value ) ) {
206
+ return value ;
207
+ }
208
+
209
+ return helpers . error ( "string.invalidUrl" ) ;
210
+ } )
211
+ . messages ( {
212
+ "string.empty" : "This field is required." ,
213
+ "string.uri" : "The URL you provided is not valid." ,
214
+ "string.invalidUrl" :
215
+ "Please enter a valid URL, hostname, or container name (with optional port)." ,
216
+ } ) ,
172
217
ignoreTlsErrors : joi . boolean ( ) . default ( false ) ,
173
218
port : joi . number ( ) ,
174
219
isActive : joi . boolean ( ) ,
0 commit comments