@@ -235,48 +235,13 @@ export class MvcValidationProviders {
235
235
if ( ! value ) {
236
236
return true ;
237
237
}
238
+
239
+ let lowerCaseValue = value . toLowerCase ( ) ;
238
240
239
- // (c) Diego Perini, MIT Licensed
240
- // https://gist.github.com/dperini/729294
241
-
242
- var r = new RegExp (
243
- "^" +
244
- // protocol identifier
245
- "(?:(?:https?|ftp)://)" +
246
- // user:pass authentication
247
- "(?:\\S+(?::\\S*)?@)?" +
248
- "(?:" +
249
- // IP address exclusion
250
- // private & local networks
251
- "(?!(?:10|127)(?:\\.\\d{1,3}){3})" +
252
- "(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})" +
253
- "(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})" +
254
- // IP address dotted notation octets
255
- // excludes loopback network 0.0.0.0
256
- // excludes reserved space >= 224.0.0.0
257
- // excludes network & broacast addresses
258
- // (first & last IP address of each class)
259
- "(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])" +
260
- "(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}" +
261
- "(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))" +
262
- "|" +
263
- // host name
264
- "(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)" +
265
- // domain name
266
- "(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*" +
267
- // TLD identifier
268
- "(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))" +
269
- // TLD may end with dot
270
- "\\.?" +
271
- ")" +
272
- // port number
273
- "(?::\\d{2,5})?" +
274
- // resource path
275
- "(?:[/?#]\\S*)?" +
276
- "$" , "i"
277
- ) ;
278
-
279
- return r . test ( value ) ;
241
+ // Match the logic in `UrlAttribute`
242
+ return lowerCaseValue . indexOf ( 'http://' ) > - 1
243
+ || lowerCaseValue . indexOf ( 'https://' ) > - 1
244
+ || lowerCaseValue . indexOf ( 'ftp://' ) > - 1 ;
280
245
}
281
246
282
247
/**
0 commit comments