咏竹莉
where there is a will,there is a way

 

const all_permissions = [
    {
        permission_id: 1,
        permission_name: "Getting User List",
        permission_method: "GET",
        permission_url: /^\/panel\/user$/
    },
    {
        permission_id: 2,
        permission_name: "Getting User Info",
        permission_method: "GET",
        permission_url: /^\/panel\/user\/[0-9]+$/
    },
    {
        permission_id: 3,
        permission_name: "Testing",
        permission_method: "GET",
        permission_url: /^\/panel\/test\/[a-z]+$/
    }
]

const my_permissions = [1,2];
const match = all_permissions.filter(p => my_permissions.includes(p.permission_id));
console.log(match)

 

posted on 2021-12-07 16:16  咏竹莉  阅读(58)  评论(0编辑  收藏  举报