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.

18 lines (17 loc) 702 B
import { getPotentialMatch } from "./getPotentialMatch.js"; export function getParams() { let params = {}; const match = getPotentialMatch(); if (match.result) { var _match_result; const values = (_match_result = match.result) === null || _match_result === void 0 ? void 0 : _match_result.slice(1); const keys = Array.from(match.route.path.matchAll(/:(\w+)/g)).map((result)=>result[1]); params = Object.fromEntries(keys.map((key, i)=>[ key, values[i] ])); } const searchParams = new URLSearchParams(window.location.search); searchParams.forEach((value, key)=>params[key] = value); return params; }