expensify-common 2.0.3 → 2.0.4
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/ExpensiMark.js +4 -1
- package/dist/str.d.ts +6 -1
- package/dist/str.js +10 -0
- package/package.json +2 -1
package/dist/ExpensiMark.js
CHANGED
|
@@ -197,7 +197,10 @@ class ExpensiMark {
|
|
|
197
197
|
name: 'userMentions',
|
|
198
198
|
regex: new RegExp(`(@here|[a-zA-Z0-9.!$%&+=?^\`{|}-]?)(@${Constants.CONST.REG_EXP.EMAIL_PART}|@${Constants.CONST.REG_EXP.PHONE_PART})(?!((?:(?!<a).)+)?<\\/a>|[^<]*(<\\/pre>|<\\/code>))`, 'gim'),
|
|
199
199
|
replacement: (match, g1, g2) => {
|
|
200
|
-
|
|
200
|
+
const phoneNumberRegex = new RegExp(`^${Constants.CONST.REG_EXP.PHONE_PART}$`);
|
|
201
|
+
const mention = g2.slice(1);
|
|
202
|
+
const mentionWithoutSMSDomain = str_1.default.removeSMSDomain(mention);
|
|
203
|
+
if (!str_1.default.isValidMention(match) || (phoneNumberRegex.test(mentionWithoutSMSDomain) && !str_1.default.isValidPhoneNumber(mentionWithoutSMSDomain))) {
|
|
201
204
|
return match;
|
|
202
205
|
}
|
|
203
206
|
const phoneRegex = new RegExp(`^@${Constants.CONST.REG_EXP.PHONE_PART}$`);
|
package/dist/str.d.ts
CHANGED
|
@@ -478,9 +478,14 @@ declare const Str: {
|
|
|
478
478
|
/**
|
|
479
479
|
* Check for whether a phone number is valid.
|
|
480
480
|
* @param phone
|
|
481
|
-
* @deprecated use isValidE164Phone to validate E.164 phone numbers or
|
|
481
|
+
* @deprecated use isValidE164Phone to validate E.164 phone numbers, isValidPhoneFormat to validate phone number format, or isValidPhoneNumber to validate phone numbers in general
|
|
482
482
|
*/
|
|
483
483
|
isValidPhone(phone: string): boolean;
|
|
484
|
+
/**
|
|
485
|
+
* Check for whether a phone number is valid.
|
|
486
|
+
* @param phone
|
|
487
|
+
*/
|
|
488
|
+
isValidPhoneNumber(phone: string): boolean;
|
|
484
489
|
/**
|
|
485
490
|
* Check for whether a phone number is valid according to E.164 standard.
|
|
486
491
|
* @param phone
|
package/dist/str.js
CHANGED
|
@@ -28,6 +28,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
/* eslint-disable no-control-regex */
|
|
30
30
|
const underscore_1 = __importDefault(require("underscore"));
|
|
31
|
+
const awesome_phonenumber_1 = require("awesome-phonenumber");
|
|
31
32
|
const HtmlEntities = __importStar(require("html-entities"));
|
|
32
33
|
const Constants = __importStar(require("./CONST"));
|
|
33
34
|
const UrlPatterns = __importStar(require("./Url"));
|
|
@@ -868,6 +869,15 @@ const Str = {
|
|
|
868
869
|
isValidPhone(phone) {
|
|
869
870
|
return Constants.CONST.SMS.E164_REGEX.test(phone);
|
|
870
871
|
},
|
|
872
|
+
/**
|
|
873
|
+
* Check for whether a phone number is valid.
|
|
874
|
+
* @param {String} phone
|
|
875
|
+
*
|
|
876
|
+
* @return {bool}
|
|
877
|
+
*/
|
|
878
|
+
isValidPhoneNumber(phone) {
|
|
879
|
+
return (0, awesome_phonenumber_1.parsePhoneNumber)(phone).possible;
|
|
880
|
+
},
|
|
871
881
|
/**
|
|
872
882
|
* Check for whether a phone number is valid according to E.164 standard.
|
|
873
883
|
* @param {String} phone
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expensify-common",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"author": "Expensify, Inc.",
|
|
5
5
|
"description": "Expensify libraries and components shared across different repos",
|
|
6
6
|
"homepage": "https://expensify.com",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"url": "git+ssh://git@github.com/Expensify/JS-Libs.git"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
+
"awesome-phonenumber": "^5.4.0",
|
|
31
32
|
"classnames": "2.5.0",
|
|
32
33
|
"clipboard": "2.0.11",
|
|
33
34
|
"eslint-plugin-you-dont-need-lodash-underscore": "^6.14.0",
|