@@ -5,6 +5,8 @@ const unescapeIRCRegex = /\\([sn:r\\])/g;
5
5
const escapeIRCRegex = / ( [ \n ; \r \\ ] ) / g;
6
6
const ircEscapedChars = { s : ' ' , n : '' , ':' : ';' , r : '' } ;
7
7
const ircUnescapedChars = { ' ' : 's' , '\n' : 'n' , ';' : ':' , '\r' : 'r' } ;
8
+ const urlRegex = new RegExp ( '^(?:(?:https?|ftp)://)(?:\\S+(?::\\S*)?@)?(?:(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?: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]))|(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))\\.?)(?::\\d{2,5})?(?:[/?#]\\S*)?$' , 'i' ) ;
9
+ const regexEmoteRegex = / [ | \\ ^ $ * + ? : # ] / ;
8
10
const _ = module . exports = {
9
11
// Return the second value if the first value is undefined..
10
12
get : ( a , b ) => typeof a === 'undefined' ? b : a ,
@@ -31,10 +33,10 @@ const _ = module.exports = {
31
33
isInteger : int => ! isNaN ( _ . toNumber ( int , 0 ) ) ,
32
34
33
35
// Value is a regex..
34
- isRegex : str => / [ | \\ ^ $ * + ? : # ] / . test ( str ) ,
36
+ isRegex : str => regexEmoteRegex . test ( str ) ,
35
37
36
38
// Value is a valid url..
37
- isURL : str => new RegExp ( '^(?:(?:https?|ftp)://)(?:\\S+(?::\\S*)?@)?(?:(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?: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]))|(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))\\.?)(?::\\d{2,5})?(?:[/?#]\\S*)?$' , 'i' ) . test ( str ) ,
39
+ isURL : str => urlRegex . test ( str ) ,
38
40
39
41
// Return a random justinfan username..
40
42
justinfan : ( ) => `justinfan${ Math . floor ( ( Math . random ( ) * 80000 ) + 1000 ) } ` ,
0 commit comments