best-matcher
v1.0.0
Published
find best matched string in list
Downloads
2
Readme
best-matcher
find the best matched string amoung a list that starts with the same prefix;
useage
import { getBestMatch } from "best-matcher";
const currentActiveMenu = getBestMatch(location.href, menus, '/')
if the routes follow the hierarchy naming rules, this function will match the most intuitive and logically correct path in the sidemenu.
eg.
if current path is /user/list/detail?uid=123
, best match will be /user/list
amoung the list of ['/user/manage', '/user/list']