Skip to content

Commit

Permalink
Merge pull request #154 from nezed-forks/153-wrong-user-in-wip-limit
Browse files Browse the repository at this point in the history
[#153] Look for exact match first
  • Loading branch information
pavelpower authored Nov 17, 2021
2 parents f73df21 + de97b8f commit 8a1d006
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/shared/jiraApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,5 +168,13 @@ export const getUser = query =>
if (res2.status === 'fulfilled') return res2.value;
})
.then(users => {
return users.find(user => user.name?.includes(query) || user.displayName?.includes(query)) ?? users[0];
if (!query) return users[0];

const exactMatch = users.find(user => user.name === query || user.displayName === query);
if (exactMatch) return exactMatch;

const substringMatch = users.find(user => user.name?.includes(query) || user.displayName?.includes(query));
if (substringMatch) return substringMatch;

return users[0];
});

0 comments on commit 8a1d006

Please sign in to comment.