mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Bump typescript, @typescript-eslint/eslint-plugin, and @typescript-eslint/parser (#6143)
This commit is contained in:
1 parent
27871f57b6
commit
b0d72b78d0
16 files changed
+105
-118
No files matched your search
@@ -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)["/"];
|
||||
}
|
||||
Reference in new issue
Block a user