Neverending Programming Mistakes

    best-matcher
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.0 • Public • Published

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

    Install

    npm i best-matcher

    DownloadsWeekly Downloads

    1

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    3.48 kB

    Total Files

    5

    Last publish

    Collaborators

    • tli4