import { pathToRegexp } from 'path-to-regexp'; export const isPathMatchingRoute = ({ currentRoute, exact, path: viewPath, sensitive, strict }) => { // if no path is defined, we cannot match it so return false early if (!viewPath) { return false; } const keys = []; // run the view path through `pathToRegexp` to resolve any dynamic segments // i.e. `/admin/custom-view/:id` -> `/admin/custom-view/123` const regex = pathToRegexp(viewPath, keys, { sensitive, strict }); const match = regex.exec(currentRoute); const viewRoute = match?.[0] || viewPath; if (exact) { return currentRoute === viewRoute; } if (!exact) { return viewRoute.startsWith(currentRoute); } }; //# sourceMappingURL=isPathMatchingRoute.js.map