Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function usePathSegments() {
const [ path, requestPath ] = usePath()
const [ , selectedTab, selectedIssueId ] = path.match(PATH_REGEX) || []
const [ , search ] = path.match(SEARCH_REGEX) || []
const selectIssue = useCallback(issueId => {
requestPath && requestPath(`/issues/${issueId || ''}`)
}, [requestPath])
const query = useMemo(() => {
if (!search) return {}
return search.split('&').reduce(
(acc, param) => {
const [ , key, value ] = param.match(SEARCH_PARAM_REGEX)
acc[key] = value
return acc
},