Skip to content

Commit 4e9720f

Browse files
feature : arrange types, now types are set to 'strict'
1 parent 53cf544 commit 4e9720f

23 files changed

+644
-517
lines changed

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
18.20.4

.prettierrc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"printWidth": 80,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"semi": true,
6+
"singleQuote": false,
7+
"trailingComma": "es5",
8+
"bracketSpacing": true,
9+
"jsxBracketSameLine": false,
10+
"arrowParens": "always",
11+
"requirePragma": false,
12+
"insertPragma": false,
13+
"proseWrap": "preserve"
14+
}

README.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,15 @@ var url = Pattern.UrlArea.parseUrl("xtp://gooppalgo.com/park/tree/?abc=1")
156156
* @param textStr string required
157157
* @param noProtocolJsn object
158158
* default : {
159-
'ip_v4' : false,
160-
'ip_v6' : false,
159+
'ipV4' : false,
160+
'ipV6' : false,
161161
'localhost' : false,
162162
'intranet' : false
163163
}
164164
165165
var urls = Pattern.TextArea.extractAllUrls(textStr, {
166-
'ip_v4' : true,
167-
'ip_v6' : false,
166+
'ipV4' : true,
167+
'ipV6' : false,
168168
'localhost' : false,
169169
'intranet' : true
170170
})
@@ -222,8 +222,8 @@ var url = Pattern.UrlArea.parseUrl("xtp://gooppalgo.com/park/tree/?abc=1")
222222

223223
``` javascript
224224

225-
var sampleText = 'https://google.com/abc/777?a=5&b=7 abc/def 333/kak abc/55에서 abc/53 abc/53a/ka /123a/abc/556/dd /abc/123?a=5&b=tkt /xyj/asff' +
226-
'a333/kak nice/guy/ bad/or/nice/guy ssh://nice.guy.com/?a=dkdfl';
225+
var sampleText = 'https://google.com/abc/777?a=5&b=7 abc/def 333/kak abc/55에서 abc/53 abc/533/ka abc/53a/ka /123a/abc/556/dd /abc/123?a=5&b=tkt /xyj/asff' +
226+
'a333/kak nice/guy/ bad/or/nice/guy ssh://nice.guy.com/?a=dkdfl';
227227

228228
/**
229229
* @brief
@@ -247,7 +247,7 @@ var sampleText = 'https://google.com/abc/777?a=5&b=7 abc/def 333/kak abc/55에
247247
``` javascript
248248
[
249249
{
250-
"uri_detected": {
250+
"uriDetected": {
251251
"value": {
252252
"url": "/abc/777?a=5&b=7",
253253
"removedTailOnUrl": "",
@@ -269,7 +269,7 @@ var sampleText = 'https://google.com/abc/777?a=5&b=7 abc/def 333/kak abc/55에
269269
"end": 34
270270
}
271271
},
272-
"in_what_url": {
272+
"inWhatUrl": {
273273
"value": {
274274
"url": "https://google.com/abc/777?a=5&b=7",
275275
"removedTailOnUrl": "",
@@ -293,7 +293,7 @@ var sampleText = 'https://google.com/abc/777?a=5&b=7 abc/def 333/kak abc/55에
293293
}
294294
},
295295
{
296-
"uri_detected": {
296+
"uriDetected": {
297297
"value": {
298298
"url": "333/kak",
299299
"removedTailOnUrl": "",
@@ -312,10 +312,10 @@ var sampleText = 'https://google.com/abc/777?a=5&b=7 abc/def 333/kak abc/55에
312312
"end": 51
313313
}
314314
},
315-
"in_what_url": null
315+
"inWhatUrl": undefined
316316
},
317317
{
318-
"uri_detected": {
318+
"uriDetected": {
319319
"value": {
320320
"url": "abc/53",
321321
"removedTailOnUrl": "",
@@ -334,10 +334,10 @@ var sampleText = 'https://google.com/abc/777?a=5&b=7 abc/def 333/kak abc/55에
334334
"end": 67
335335
}
336336
},
337-
"in_what_url": null
337+
"inWhatUrl": undefined
338338
},
339339
{
340-
"uri_detected": {
340+
"uriDetected": {
341341
"value": {
342342
"url": "abc/533/ka",
343343
"removedTailOnUrl": "",
@@ -356,10 +356,10 @@ var sampleText = 'https://google.com/abc/777?a=5&b=7 abc/def 333/kak abc/55에
356356
"end": 77
357357
}
358358
},
359-
"in_what_url": null
359+
"inWhatUrl": undefined
360360
},
361361
{
362-
"uri_detected": {
362+
"uriDetected": {
363363
"value": {
364364
"url": "/123a/abc/556/dd",
365365
"removedTailOnUrl": "",
@@ -378,10 +378,10 @@ var sampleText = 'https://google.com/abc/777?a=5&b=7 abc/def 333/kak abc/55에
378378
"end": 105
379379
}
380380
},
381-
"in_what_url": null
381+
"inWhatUrl": undefined
382382
},
383383
{
384-
"uri_detected": {
384+
"uriDetected": {
385385
"value": {
386386
"url": "/abc/123?a=5&b=tkt",
387387
"removedTailOnUrl": "",
@@ -403,10 +403,10 @@ var sampleText = 'https://google.com/abc/777?a=5&b=7 abc/def 333/kak abc/55에
403403
"end": 124
404404
}
405405
},
406-
"in_what_url": null
406+
"inWhatUrl": undefined
407407
},
408408
{
409-
"uri_detected": {
409+
"uriDetected": {
410410
"value": {
411411
"url": "nice/guy",
412412
"removedTailOnUrl": "/",
@@ -425,10 +425,10 @@ var sampleText = 'https://google.com/abc/777?a=5&b=7 abc/def 333/kak abc/55에
425425
"end": 153
426426
}
427427
},
428-
"in_what_url": null
428+
"inWhatUrl": undefined
429429
},
430430
{
431-
"uri_detected": {
431+
"uriDetected": {
432432
"value": {
433433
"url": "/or/nice/guy",
434434
"removedTailOnUrl": "",
@@ -447,7 +447,7 @@ var sampleText = 'https://google.com/abc/777?a=5&b=7 abc/def 333/kak abc/55에
447447
"end": 170
448448
}
449449
},
450-
"in_what_url": null
450+
"inWhatUrl": null
451451
}
452452
]
453453
```

dist/controller.js

Lines changed: 35 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)