UNPKG

@saber2pr/router

Version:

> react-router-dom by hooks api.

19 lines (18 loc) 662 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); // `/repo/react` matched `/repo` instead of `/` function getMaxLenChildStr(map, query) { if (query === void 0) { query = ""; } var maxLenStrs = Object.keys(map).sort(function (a, b) { return b.length - a.length; }); return maxLenStrs.find(function (s) { return (s === "/" ? query === s : query.startsWith(s)); }); } exports.getMaxLenChildStr = getMaxLenChildStr; function execute(map, route) { if (!route) return; route = decodeURIComponent(route); route = getMaxLenChildStr(map, route); map[route](); return route; } exports.execute = execute;