| Conditions | 1 |
| Paths | 1 |
| Total Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | import React from 'react'; |
||
| 4 | function getParams(activeRoute, path) { |
||
| 5 | const splitRoute = activeRoute.split('/'); |
||
| 6 | const splitPath = path.split('/'); |
||
| 7 | const params = splitRoute.reduce((param, route, index) => { |
||
| 8 | if (route.match(':')) { |
||
| 9 | param[route.substr(1)] = splitPath[index]; |
||
| 10 | } |
||
| 11 | return param; |
||
| 12 | }, {}); |
||
| 13 | const trueRoute = splitRoute.reduce((newRoute, routeFrag) => { |
||
| 14 | newRoute.push(params[routeFrag.substr(1)] || routeFrag) |
||
| 15 | return newRoute; |
||
| 16 | }, []).join('/'); |
||
| 17 | return { trueRoute, params }; |
||
| 18 | } |
||
| 19 | |||
| 64 |