@@ -21,22 +21,21 @@ const TextArea = {
21
21
* @param textStr string required
22
22
* @param noProtocolJsn object
23
23
* default : {
24
- 'ip_v4 ' : false,
25
- 'ip_v6 ' : false,
24
+ 'ipV4 ' : false,
25
+ 'ipV6 ' : false,
26
26
'localhost' : false,
27
27
'intranet' : false
28
28
}
29
29
30
30
* @return array
31
31
*/
32
32
extractAllUrls ( textStr , noProtocolJsn = {
33
- ip_v4 : false ,
34
- ip_v6 : false ,
33
+ ipV4 : false ,
34
+ ipV6 : false ,
35
35
localhost : false ,
36
36
intranet : false
37
37
} ) {
38
38
OptionalUrlPatternBuilder_1 . OptionalUrlPatternBuilder . setUrlPattern ( noProtocolJsn ) ;
39
- //console.log('a : ' + Pattern.Children.url);
40
39
return service_1 . default . Text . extractAllPureUrls ( textStr ) ;
41
40
} ,
42
41
/**
@@ -74,37 +73,34 @@ const TextArea = {
74
73
let obj_final = [ ] ;
75
74
for ( let a = 0 ; a < obj . length ; a ++ ) {
76
75
let obj_part = {
77
- 'uri_detected' : null ,
78
- 'in_what_url' : null ,
76
+ uriDetected : undefined ,
77
+ inWhatUrl : undefined ,
79
78
} ;
80
79
//let matchedUrlFound = false;
81
80
for ( let b = 0 ; b < obj2 . length ; b ++ ) {
82
- /* console.log('obj : ' + JSON.stringify(obj[a]));
83
- console.log('obj2 : ' + JSON.stringify(obj2[b]));*/
84
- if ( ( obj [ a ] [ 'index' ] [ 'start' ] > obj2 [ b ] [ 'index' ] [ 'start' ] && obj [ a ] [ 'index' ] [ 'start' ] < obj2 [ b ] [ 'index' ] [ 'end' ] )
81
+ if ( ( obj [ a ] . index . start > obj2 [ b ] . index . start && obj [ a ] . index . start < obj2 [ b ] . index . end )
85
82
&&
86
- ( obj [ a ] [ ' index' ] [ ' end' ] > obj2 [ b ] [ ' index' ] [ ' start' ] && obj [ a ] [ ' index' ] [ ' end' ] <= obj2 [ b ] [ ' index' ] [ ' end' ] ) ) {
83
+ ( obj [ a ] . index . end > obj2 [ b ] . index . start && obj [ a ] . index . end <= obj2 [ b ] . index . end ) ) {
87
84
// Here, the uri detected is inside its url
88
85
// false positives like the example '//google.com/abc/def?a=5&b=7' can be detected in 'Service.Text.extractCertainPureUris'
89
- let sanitizedUrl = obj [ a ] [ 'value' ] [ 'url' ] ;
86
+ let sanitizedUrl = obj [ a ] [ 'value' ] [ 'url' ] || "" ;
90
87
let rx = new RegExp ( '^(\\/\\/[^/]*|\\/[^\\s]+\\.' + DomainPatterns_1 . DomainPatterns . allRootDomains + ')' , 'gi' ) ;
91
88
let matches = [ ] ;
92
- let match = { } ;
93
- while ( ( match = rx . exec ( obj [ a ] [ ' value' ] [ ' url' ] ) ) !== null ) {
89
+ let match ;
90
+ while ( ( match = rx . exec ( obj [ a ] . value . url || "" ) ) !== null ) {
94
91
if ( match [ 1 ] ) {
95
92
sanitizedUrl = sanitizedUrl . replace ( rx , '' ) ;
96
93
//console.log(match[1]);
97
- obj [ a ] [ ' value' ] [ ' url' ] = sanitizedUrl ;
98
- obj [ a ] [ ' index' ] [ ' start' ] += match [ 1 ] . length ;
99
- obj [ a ] [ ' value' ] [ ' onlyUriWithParams' ] = obj [ a ] [ ' value' ] [ ' url' ] ;
100
- obj [ a ] [ ' value' ] [ ' onlyUri' ] = obj [ a ] [ ' value' ] [ ' url' ] . replace ( / \? [ ^ / ] * $ / gi, '' ) ;
94
+ obj [ a ] . value . url = sanitizedUrl ;
95
+ obj [ a ] . index . start += match [ 1 ] . length ;
96
+ obj [ a ] . value . onlyUriWithParams = obj [ a ] . value . url ;
97
+ obj [ a ] . value . onlyUri = ( obj [ a ] . value . url || "" ) . replace ( / \? [ ^ / ] * $ / gi, '' ) ;
101
98
}
102
99
}
103
- obj_part . in_what_url = obj2 [ b ] ;
104
- //matchedUrlFound = true;
100
+ obj_part . inWhatUrl = obj2 [ b ] ;
105
101
}
106
102
}
107
- obj_part . uri_detected = obj [ a ] ;
103
+ obj_part . uriDetected = obj [ a ] ;
108
104
obj_final . push ( obj_part ) ;
109
105
}
110
106
return obj_final ;
@@ -148,11 +144,11 @@ const XmlArea = {
148
144
if ( ! ( xmlStr && typeof xmlStr === 'string' ) ) {
149
145
throw new Error ( 'the variable xmlStr must be a string type and not be null.' ) ;
150
146
}
151
- const cmt_matches = service_1 . default . Xml . extractAllPureComments ( xmlStr ) ;
147
+ const cmtMatches = service_1 . default . Xml . extractAllPureComments ( xmlStr ) ;
152
148
let matches = service_1 . default . Xml . extractAllPureElements ( xmlStr ) ;
153
149
for ( let a = 0 ; a < matches . length ; a ++ ) {
154
- for ( let i = 0 ; i < cmt_matches . length ; i ++ ) {
155
- if ( cmt_matches [ i ] . startIndex < matches [ a ] . startIndex && matches [ a ] . lastIndex < cmt_matches [ i ] . lastIndex ) {
150
+ for ( let i = 0 ; i < cmtMatches . length ; i ++ ) {
151
+ if ( cmtMatches [ i ] . startIndex < matches [ a ] . startIndex && matches [ a ] . lastIndex < cmtMatches [ i ] . lastIndex ) {
156
152
matches [ a ] [ 'commentArea' ] = true ;
157
153
break ;
158
154
}
@@ -196,8 +192,8 @@ const XmlArea = {
196
192
* @param skipXml boolean (default : false)
197
193
* @param noProtocolJsn object
198
194
* default : {
199
- 'ip_v4 ' : false,
200
- 'ip_v6 ' : false,
195
+ 'ipV4 ' : false,
196
+ 'ipV6 ' : false,
201
197
'localhost' : false,
202
198
'intranet' : false
203
199
}
@@ -210,14 +206,14 @@ const XmlArea = {
210
206
OptionalUrlPatternBuilder_1 . OptionalUrlPatternBuilder . setUrlPattern ( noProtocolJsn ) ;
211
207
let obj = [ ] ;
212
208
if ( ! skipXml ) {
213
- let cmt_matches = XmlArea . extractAllComments ( xmlStr ) ;
214
- let el_matches = XmlArea . extractAllElements ( xmlStr ) ;
209
+ let cmtMatches = XmlArea . extractAllComments ( xmlStr ) ;
210
+ let elMatches = XmlArea . extractAllElements ( xmlStr ) ;
215
211
/* 1. comment */
216
- for ( let a = 0 ; a < cmt_matches . length ; a ++ ) {
212
+ for ( let a = 0 ; a < cmtMatches . length ; a ++ ) {
217
213
let rx = new RegExp ( OptionalUrlPatternBuilder_1 . OptionalUrlPatternBuilder . getUrl , 'gi' ) ;
218
214
let matches = [ ] ;
219
- let match = { } ;
220
- while ( ( match = rx . exec ( cmt_matches [ a ] . value ) ) !== null ) {
215
+ let match ;
216
+ while ( ( match = rx . exec ( cmtMatches [ a ] . value ) ) !== null ) {
221
217
/* remove email patterns related to 'all_urls3_front' regex */
222
218
if ( / ^ @ / . test ( match [ 0 ] ) ) {
223
219
continue ;
@@ -233,11 +229,11 @@ const XmlArea = {
233
229
}
234
230
}
235
231
/* 2. element */
236
- for ( let a = 0 ; a < el_matches . length ; a ++ ) {
232
+ for ( let a = 0 ; a < elMatches . length ; a ++ ) {
237
233
let rx = new RegExp ( OptionalUrlPatternBuilder_1 . OptionalUrlPatternBuilder . getUrl , 'gi' ) ;
238
234
let matches = [ ] ;
239
- let match = { } ;
240
- while ( ( match = rx . exec ( el_matches [ a ] . value ) ) !== null ) {
235
+ let match ;
236
+ while ( ( match = rx . exec ( elMatches [ a ] . value ) ) !== null ) {
241
237
/* remove email patterns related to 'all_urls3_front' regex */
242
238
if ( / ^ @ / . test ( match [ 0 ] ) ) {
243
239
continue ;
@@ -248,7 +244,7 @@ const XmlArea = {
248
244
//mod_val = mod_val.trim();
249
245
obj . push ( {
250
246
'value' : service_1 . default . Url . parseUrl ( mod_val ) ,
251
- 'area' : 'element : ' + el_matches [ a ] . elementName
247
+ 'area' : 'element : ' + elMatches [ a ] . elementName
252
248
} ) ;
253
249
}
254
250
}
@@ -262,7 +258,7 @@ const XmlArea = {
262
258
/* 5. normal text area */
263
259
let rx = new RegExp ( OptionalUrlPatternBuilder_1 . OptionalUrlPatternBuilder . getUrl , 'gi' ) ;
264
260
let matches = [ ] ;
265
- let match = { } ;
261
+ let match ;
266
262
while ( ( match = rx . exec ( xmlStr ) ) !== null ) {
267
263
/* remove email patterns related to 'all_urls3_front' regex */
268
264
if ( / ^ @ / . test ( match [ 0 ] ) ) {
@@ -310,7 +306,7 @@ const XmlArea = {
310
306
for ( let a = 0 ; a < cmt_matches . length ; a ++ ) {
311
307
let rx = new RegExp ( EmailPatternBuilder_1 . EmailPatternBuilder . getEmail , 'gi' ) ;
312
308
let matches = [ ] ;
313
- let match = { } ;
309
+ let match ;
314
310
while ( ( match = rx . exec ( cmt_matches [ a ] . value ) ) !== null ) {
315
311
/* comment - regex conflict case handler */
316
312
let mod_val = match [ 0 ] . replace ( / - - > $ / , '' ) ;
@@ -342,7 +338,7 @@ const XmlArea = {
342
338
for ( let a = 0 ; a < el_matches . length ; a ++ ) {
343
339
let rx = new RegExp ( EmailPatternBuilder_1 . EmailPatternBuilder . getEmail , 'gi' ) ;
344
340
let matches = [ ] ;
345
- let match = { } ;
341
+ let match ;
346
342
while ( ( match = rx . exec ( el_matches [ a ] . value ) ) !== null ) {
347
343
/* attribute value - regex conflict case handler */
348
344
let mod_val = match [ 0 ] . replace ( new RegExp ( '[\\u0022\\u0027](?:[\\t\\s]+|[\\t\\s]*/[\\t\\s]*)(?:>|)' , 'gi' ) , '' ) ;
@@ -379,7 +375,7 @@ const XmlArea = {
379
375
/* 5. normal text area */
380
376
let rx = new RegExp ( EmailPatternBuilder_1 . EmailPatternBuilder . getEmail , 'gi' ) ;
381
377
let matches = [ ] ;
382
- let match = { } ;
378
+ let match ;
383
379
while ( ( match = rx . exec ( xmlStr ) ) !== null ) {
384
380
let mod_val = match [ 0 ] ;
385
381
mod_val = mod_val . replace ( / [ \n \r \t \s ] / g, '' ) ;
0 commit comments