@jay-js/system
Version:
A powerful and flexible TypeScript library for UI, state management, lazy loading, routing and managing draggable elements in modern web applications.
19 lines (18 loc) • 576 B
JavaScript
import { getPotentialMatches } from "./getPotentialMatches.js";
import { resolvedRoutes } from "./routerDefineOptions.js";
export function getPotentialMatchIndex() {
const potentialMatches = getPotentialMatches();
if (potentialMatches.length === 0) {
const firstRoute = resolvedRoutes.values().next().value;
return {
route: firstRoute,
result: [
location.pathname
]
};
}
if (potentialMatches.length === 2) {
return potentialMatches[1];
}
return potentialMatches[0];
}