UNPKG

@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.

20 lines (19 loc) 649 B
import { pathToRegex } from "../utils/pathToRegex.js"; import { resolvedRoutes } from "./routerDefineOptions.js"; export function getPotentialMatches() { let pathName = location.pathname; if (pathName.substring(pathName.length - 1) === "/") { pathName = pathName.substring(0, pathName.length - 1); } const potentialMatches = []; for (const route of resolvedRoutes.values()){ const result = pathName.match(pathToRegex(route.path)); if (result) { potentialMatches.push({ route: route, result: result }); } } return potentialMatches; }