(path, routeData)
| 24 | return undefined; |
| 25 | }; |
| 26 | export const getRouteAuthority = (path, routeData) => { |
| 27 | let authorities; |
| 28 | routeData.forEach(route => { |
| 29 | // match prefix |
| 30 | if (pathRegexp(`${route.path}/(.*)`).test(`${path}/`)) { |
| 31 | if (route.authority) { |
| 32 | authorities = route.authority; |
| 33 | } // exact match |
| 34 | |
| 35 | if (route.path === path) { |
| 36 | authorities = route.authority || authorities; |
| 37 | } // get children authority recursively |
| 38 | |
| 39 | if (route.routes) { |
| 40 | authorities = getRouteAuthority(path, route.routes) || authorities; |
| 41 | } |
| 42 | } |
| 43 | }); |
| 44 | return authorities; |
| 45 | }; |
| 46 | |
| 47 | /** |
| 48 | * 替换当前地址中的REQUEST_IP 通配符 |
no outgoing calls
no test coverage detected