@@ -21,22 +21,21 @@ const TextArea = {
2121 * @param textStr string required
2222 * @param noProtocolJsn object
2323 * default : {
24- 'ip_v4 ' : false,
25- 'ip_v6 ' : false,
24+ 'ipV4 ' : false,
25+ 'ipV6 ' : false,
2626 'localhost' : false,
2727 'intranet' : false
2828 }
2929
3030 * @return array
3131 */
3232 extractAllUrls ( textStr , noProtocolJsn = {
33- ip_v4 : false ,
34- ip_v6 : false ,
33+ ipV4 : false ,
34+ ipV6 : false ,
3535 localhost : false ,
3636 intranet : false
3737 } ) {
3838 OptionalUrlPatternBuilder_1 . OptionalUrlPatternBuilder . setUrlPattern ( noProtocolJsn ) ;
39- //console.log('a : ' + Pattern.Children.url);
4039 return service_1 . default . Text . extractAllPureUrls ( textStr ) ;
4140 } ,
4241 /**
@@ -74,37 +73,34 @@ const TextArea = {
7473 let obj_final = [ ] ;
7574 for ( let a = 0 ; a < obj . length ; a ++ ) {
7675 let obj_part = {
77- 'uri_detected' : null ,
78- 'in_what_url' : null ,
76+ uriDetected : undefined ,
77+ inWhatUrl : undefined ,
7978 } ;
8079 //let matchedUrlFound = false;
8180 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 )
8582 &&
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 ) ) {
8784 // Here, the uri detected is inside its url
8885 // 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' ] || "" ;
9087 let rx = new RegExp ( '^(\\/\\/[^/]*|\\/[^\\s]+\\.' + DomainPatterns_1 . DomainPatterns . allRootDomains + ')' , 'gi' ) ;
9188 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 ) {
9491 if ( match [ 1 ] ) {
9592 sanitizedUrl = sanitizedUrl . replace ( rx , '' ) ;
9693 //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, '' ) ;
10198 }
10299 }
103- obj_part . in_what_url = obj2 [ b ] ;
104- //matchedUrlFound = true;
100+ obj_part . inWhatUrl = obj2 [ b ] ;
105101 }
106102 }
107- obj_part . uri_detected = obj [ a ] ;
103+ obj_part . uriDetected = obj [ a ] ;
108104 obj_final . push ( obj_part ) ;
109105 }
110106 return obj_final ;
@@ -148,11 +144,11 @@ const XmlArea = {
148144 if ( ! ( xmlStr && typeof xmlStr === 'string' ) ) {
149145 throw new Error ( 'the variable xmlStr must be a string type and not be null.' ) ;
150146 }
151- const cmt_matches = service_1 . default . Xml . extractAllPureComments ( xmlStr ) ;
147+ const cmtMatches = service_1 . default . Xml . extractAllPureComments ( xmlStr ) ;
152148 let matches = service_1 . default . Xml . extractAllPureElements ( xmlStr ) ;
153149 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 ) {
156152 matches [ a ] [ 'commentArea' ] = true ;
157153 break ;
158154 }
@@ -196,8 +192,8 @@ const XmlArea = {
196192 * @param skipXml boolean (default : false)
197193 * @param noProtocolJsn object
198194 * default : {
199- 'ip_v4 ' : false,
200- 'ip_v6 ' : false,
195+ 'ipV4 ' : false,
196+ 'ipV6 ' : false,
201197 'localhost' : false,
202198 'intranet' : false
203199 }
@@ -210,14 +206,14 @@ const XmlArea = {
210206 OptionalUrlPatternBuilder_1 . OptionalUrlPatternBuilder . setUrlPattern ( noProtocolJsn ) ;
211207 let obj = [ ] ;
212208 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 ) ;
215211 /* 1. comment */
216- for ( let a = 0 ; a < cmt_matches . length ; a ++ ) {
212+ for ( let a = 0 ; a < cmtMatches . length ; a ++ ) {
217213 let rx = new RegExp ( OptionalUrlPatternBuilder_1 . OptionalUrlPatternBuilder . getUrl , 'gi' ) ;
218214 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 ) {
221217 /* remove email patterns related to 'all_urls3_front' regex */
222218 if ( / ^ @ / . test ( match [ 0 ] ) ) {
223219 continue ;
@@ -233,11 +229,11 @@ const XmlArea = {
233229 }
234230 }
235231 /* 2. element */
236- for ( let a = 0 ; a < el_matches . length ; a ++ ) {
232+ for ( let a = 0 ; a < elMatches . length ; a ++ ) {
237233 let rx = new RegExp ( OptionalUrlPatternBuilder_1 . OptionalUrlPatternBuilder . getUrl , 'gi' ) ;
238234 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 ) {
241237 /* remove email patterns related to 'all_urls3_front' regex */
242238 if ( / ^ @ / . test ( match [ 0 ] ) ) {
243239 continue ;
@@ -248,7 +244,7 @@ const XmlArea = {
248244 //mod_val = mod_val.trim();
249245 obj . push ( {
250246 'value' : service_1 . default . Url . parseUrl ( mod_val ) ,
251- 'area' : 'element : ' + el_matches [ a ] . elementName
247+ 'area' : 'element : ' + elMatches [ a ] . elementName
252248 } ) ;
253249 }
254250 }
@@ -262,7 +258,7 @@ const XmlArea = {
262258 /* 5. normal text area */
263259 let rx = new RegExp ( OptionalUrlPatternBuilder_1 . OptionalUrlPatternBuilder . getUrl , 'gi' ) ;
264260 let matches = [ ] ;
265- let match = { } ;
261+ let match ;
266262 while ( ( match = rx . exec ( xmlStr ) ) !== null ) {
267263 /* remove email patterns related to 'all_urls3_front' regex */
268264 if ( / ^ @ / . test ( match [ 0 ] ) ) {
@@ -310,7 +306,7 @@ const XmlArea = {
310306 for ( let a = 0 ; a < cmt_matches . length ; a ++ ) {
311307 let rx = new RegExp ( EmailPatternBuilder_1 . EmailPatternBuilder . getEmail , 'gi' ) ;
312308 let matches = [ ] ;
313- let match = { } ;
309+ let match ;
314310 while ( ( match = rx . exec ( cmt_matches [ a ] . value ) ) !== null ) {
315311 /* comment - regex conflict case handler */
316312 let mod_val = match [ 0 ] . replace ( / - - > $ / , '' ) ;
@@ -342,7 +338,7 @@ const XmlArea = {
342338 for ( let a = 0 ; a < el_matches . length ; a ++ ) {
343339 let rx = new RegExp ( EmailPatternBuilder_1 . EmailPatternBuilder . getEmail , 'gi' ) ;
344340 let matches = [ ] ;
345- let match = { } ;
341+ let match ;
346342 while ( ( match = rx . exec ( el_matches [ a ] . value ) ) !== null ) {
347343 /* attribute value - regex conflict case handler */
348344 let mod_val = match [ 0 ] . replace ( new RegExp ( '[\\u0022\\u0027](?:[\\t\\s]+|[\\t\\s]*/[\\t\\s]*)(?:>|)' , 'gi' ) , '' ) ;
@@ -379,7 +375,7 @@ const XmlArea = {
379375 /* 5. normal text area */
380376 let rx = new RegExp ( EmailPatternBuilder_1 . EmailPatternBuilder . getEmail , 'gi' ) ;
381377 let matches = [ ] ;
382- let match = { } ;
378+ let match ;
383379 while ( ( match = rx . exec ( xmlStr ) ) !== null ) {
384380 let mod_val = match [ 0 ] ;
385381 mod_val = mod_val . replace ( / [ \n \r \t \s ] / g, '' ) ;
0 commit comments