blob: 40f50b7ccf29549fb01008761e8dbef0ee860a83 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
|
export const closest = (path: string, suggestions: string[]) => {
const partialMatch = suggestions.find((suggestion) => suggestion.includes(path));
if (partialMatch) return partialMatch;
const closestMatch = suggestions.reduce((prev, curr) => {
return prev.length > curr.length ? prev : curr;
}, '');
return closestMatch;
};
|