Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed: You can't search a room with names like "x.y" #13186

Merged
merged 7 commits into from
Dec 2, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function getParticipantNames(personalDetailList) {
}

/**
* A very optimized method to remove unique items from an array.
* A very optimized method to remove duplicates from an array.
s77rt marked this conversation as resolved.
Show resolved Hide resolved
* Taken from https://stackoverflow.com/a/9229821/9114791
*
* @param {Array} items
Expand Down Expand Up @@ -186,7 +186,7 @@ function getSearchText(report, reportName, personalDetailList, isChatRoomOrPolic
if (!isChatRoomOrPolicyExpenseChat) {
for (let i = 0; i < personalDetailList.length; i++) {
const personalDetail = personalDetailList[i];
searchTerms = searchTerms.concat([personalDetail.displayName, personalDetail.login.replace(/\./g, '')]);
searchTerms = searchTerms.concat([personalDetail.displayName, personalDetail.login, personalDetail.login.replace(/\.(?=[^\s@]*@)/g, '')]);
s77rt marked this conversation as resolved.
Show resolved Hide resolved
s77rt marked this conversation as resolved.
Show resolved Hide resolved
}
}
if (report) {
Expand Down Expand Up @@ -381,16 +381,13 @@ function createOption(logins, personalDetails, report, reportActions = {}, {
* @returns {Boolean}
*/
function isSearchStringMatch(searchValue, searchText, participantNames = new Set(), isChatRoom = false) {
const searchWords = _.map(
searchValue
.replace(/\./g, '')
.replace(/,/g, ' ')
.split(' '),
word => word.trim(),
);
return _.every(searchWords, (word) => {
const searchWords = _.compact(uniqFast([
searchValue,
..._.map(searchValue.replace(/,/g, ' ').split(' '), word => word.trim()),
]));
const valueToSearch = searchText && searchText.replace(new RegExp(/&nbsp;/g), '');
return _.some(searchWords, (word) => {
const matchRegex = new RegExp(Str.escapeForRegExp(word), 'i');
const valueToSearch = searchText && searchText.replace(new RegExp(/&nbsp;/g), '');
return matchRegex.test(valueToSearch) || (!isChatRoom && participantNames.has(word));
});
}
Expand Down