1.0.0 • Published 3 years ago

best-matcher v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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']