@diia-inhouse/diia-logger 4.5.7 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/redactors/phone.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
//#region src/redactors/phone.ts
|
|
2
2
|
const PHONE_CANDIDATE = /\+?\d[\d\s().-]{7,18}\d/g;
|
|
3
|
-
const
|
|
4
|
-
const
|
|
3
|
+
const minDigits = 10;
|
|
4
|
+
const maxDigits = 15;
|
|
5
5
|
const subscriberDigits = 7;
|
|
6
6
|
function redactPhone(text) {
|
|
7
7
|
return text.replace(PHONE_CANDIDATE, (match) => maskPhone(match));
|
|
8
8
|
}
|
|
9
9
|
function maskPhone(match) {
|
|
10
10
|
const digits = match.replace(/\D/g, "");
|
|
11
|
-
|
|
12
|
-
const isInternational = digits.length === internationalDigits;
|
|
13
|
-
if (!isNational && !isInternational) return match;
|
|
11
|
+
if (digits.length < minDigits || digits.length > maxDigits) return match;
|
|
14
12
|
return `${match.startsWith("+") ? "+" : ""}${digits.slice(0, -subscriberDigits)}${"*".repeat(subscriberDigits - 1)}${digits.slice(-1)}`;
|
|
15
13
|
}
|
|
16
14
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diia-inhouse/diia-logger",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Logger package",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@diia-inhouse/configs": "7.2.2",
|
|
45
45
|
"@diia-inhouse/eslint-plugin": "1.9.13",
|
|
46
46
|
"@diia-inhouse/oxc-config": "3.0.4",
|
|
47
|
-
"@diia-inhouse/types": "14.2.
|
|
47
|
+
"@diia-inhouse/types": "14.2.15",
|
|
48
48
|
"@diia-inhouse/utils": "6.1.15",
|
|
49
49
|
"@types/lodash": "4.17.24",
|
|
50
50
|
"@vitest/coverage-v8": "4.1.11",
|
package/src/redactors/phone.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// parentheses, dots and dashes. Validated by digit count in maskPhone.
|
|
3
3
|
const PHONE_CANDIDATE = /\+?\d[\d\s().-]{7,18}\d/g
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const minDigits = 10
|
|
6
|
+
const maxDigits = 15
|
|
7
7
|
const subscriberDigits = 7
|
|
8
8
|
|
|
9
9
|
export function redactPhone(text: string): string {
|
|
@@ -12,9 +12,7 @@ export function redactPhone(text: string): string {
|
|
|
12
12
|
|
|
13
13
|
function maskPhone(match: string): string {
|
|
14
14
|
const digits = match.replace(/\D/g, '')
|
|
15
|
-
|
|
16
|
-
const isInternational = digits.length === internationalDigits
|
|
17
|
-
if (!isNational && !isInternational) {
|
|
15
|
+
if (digits.length < minDigits || digits.length > maxDigits) {
|
|
18
16
|
return match
|
|
19
17
|
}
|
|
20
18
|
|