Skip to content

Commit

Permalink
change reg exp
Browse files Browse the repository at this point in the history
  • Loading branch information
narefyev91 committed Mar 1, 2023
1 parent 70b1d52 commit 67ea1a5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,7 @@ const CONST = {
DIGITS_AND_PLUS: /^\+?[0-9]*$/,
PHONE_E164_PLUS: /^\+?[1-9]\d{1,14}$/,
PHONE_WITH_SPECIAL_CHARS: /^[+]*[(]{0,1}[0-9]{1,3}[)]{0,1}[-\s\\./0-9]{0,12}$/,
PHONE_WITH_ANY_CHARS: /^\s*(?:\+?(\d{1,3}))?[-. (]*(\d{3})[-. )]*(\d{3})[-. ]*(\d{4})(?: *x(\d+))?\s*$/,
ALPHABETIC_CHARS: /[a-zA-Z]+/,
POSITIVE_INTEGER: /^\d+$/,
NON_ALPHA_NUMERIC: /[^A-Za-z0-9+]/g,
Expand Down
2 changes: 1 addition & 1 deletion src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ function getOptions(reports, personalDetails, {
let recentReportOptions = [];
let personalDetailsOptions = [];
const reportMapForLogins = {};
const isPhoneNumber = CONST.REGEX.PHONE_WITH_SPECIAL_CHARS.test(searchInputValue);
const isPhoneNumber = CONST.REGEX.PHONE_WITH_ANY_CHARS.test(searchInputValue);
const searchValue = isPhoneNumber ? searchInputValue.replace(CONST.REGEX.NON_NUMERIC_WITH_PLUS, '') : searchInputValue;

// Filter out all the reports that shouldn't be displayed
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/OptionsListUtilsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,14 +517,14 @@ describe('OptionsListUtils', () => {

// When we add a search term for which no options exist and the searchValue itself
// is a potential phone number with special characters added
results = OptionsListUtils.getNewChatOptions(REPORTS, PERSONAL_DETAILS, [], '(800) 324-323');
results = OptionsListUtils.getNewChatOptions(REPORTS, PERSONAL_DETAILS, [], '+1 (800)324-3233');

// Then we should have no options or personal details at all but there should be a userToInvite and the login
// should have the country code included
expect(results.recentReports.length).toBe(0);
expect(results.personalDetails.length).toBe(0);
expect(results.userToInvite).not.toBe(null);
expect(results.userToInvite.login).toBe('+1800324323');
expect(results.userToInvite.login).toBe('+18003243233');

// Test Concierge's existence in new group options
results = OptionsListUtils.getNewChatOptions(REPORTS_WITH_CONCIERGE, PERSONAL_DETAILS_WITH_CONCIERGE);
Expand Down

0 comments on commit 67ea1a5

Please sign in to comment.