import { compile } from 'path-to-regexp'; export function usePath() { function getPath(path: string, data: Recordable): string { if (path.includes(':')) { const toPath = compile(path, { encode: encodeURIComponent }); return toPath(data); } return path; } return { getPath, }; }