Bump typescript, @typescript-eslint/eslint-plugin, and @typescript-eslint/parser (#6143)

This commit is contained in:
Sebastian Malton authored and GitHub committed 2022-09-01 10:05:32 -04:00
1 parent 27871f57b6
commit b0d72b78d0
16 files changed
+105 -118

No files matched your search

+11 -19
View File
@@ -113,7 +113,17 @@ export abstract class LensProtocolRouter {
}
// if no exact match pick the one that is the most specific
return matches.sort(([a], [b]) => compareMatches(a, b))[0] ?? null;
return matches.sort(([a], [b]) => {
if (a.path === "/") {
return 1;
}
if (b.path === "/") {
return -1;
}
return countBy(b.path)["/"] - countBy(a.path)["/"];
})[0] ?? null;
}
/**
@@ -265,21 +275,3 @@ export abstract class LensProtocolRouter {
this.internalRoutes.delete(urlSchema);
}
}
/**
* a comparison function for `array.sort(...)`. Sort order should be most path
* parts to least path parts.
* @param a the left side to compare
* @param b the right side to compare
*/
function compareMatches<T>(a: match<T>, b: match<T>): number {
if (a.path === "/") {
return 1;
}
if (b.path === "/") {
return -1;
}
return countBy(b.path)["/"] - countBy(a.path)["/"];
}