Skip to content

Commit de97b8f

Browse files
author
Dmitry Naumov [MBP15]
committed
[#153] Look for exact match first
1 parent f73df21 commit de97b8f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/shared/jiraApi.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,5 +168,13 @@ export const getUser = query =>
168168
if (res2.status === 'fulfilled') return res2.value;
169169
})
170170
.then(users => {
171-
return users.find(user => user.name?.includes(query) || user.displayName?.includes(query)) ?? users[0];
171+
if (!query) return users[0];
172+
173+
const exactMatch = users.find(user => user.name === query || user.displayName === query);
174+
if (exactMatch) return exactMatch;
175+
176+
const substringMatch = users.find(user => user.name?.includes(query) || user.displayName?.includes(query));
177+
if (substringMatch) return substringMatch;
178+
179+
return users[0];
172180
});

0 commit comments

Comments
 (0)