aboutsummaryrefslogtreecommitdiff
path: root/src/lib/Error
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-02-17 01:04:25 -0800
committerFuwn <[email protected]>2024-02-17 01:04:25 -0800
commite234a5cc27d1fa4d3583523ebc173d5527e3c27f (patch)
tree8d26a694da27f6c723a7341d95d5b0718acaeaac /src/lib/Error
parentrefactor(hololive): single pinned fetch (diff)
downloaddue.moe-e234a5cc27d1fa4d3583523ebc173d5527e3c27f.tar.xz
due.moe-e234a5cc27d1fa4d3583523ebc173d5527e3c27f.zip
fix(error): return partial match in closest
Diffstat (limited to 'src/lib/Error')
-rw-r--r--src/lib/Error/path.ts4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/lib/Error/path.ts b/src/lib/Error/path.ts
index 75c035d7..1e36268c 100644
--- a/src/lib/Error/path.ts
+++ b/src/lib/Error/path.ts
@@ -1,6 +1,10 @@
import levenshtein from 'fast-levenshtein';
export const closest = (path: string, suggestions: string[]) => {
+ const partialMatches = suggestions.filter((suggestion) => suggestion.includes(path));
+
+ if (partialMatches.length) return partialMatches[0];
+
const suggestionsWithDistance = suggestions.map((suggestion) => {
const distance = levenshtein.get(path, suggestion);