Files
SaaS-lib/lib/use/use-path.ts
xuziqiang d0155dbe3c push
2024-05-15 17:29:42 +08:00

16 lines
316 B
TypeScript

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,
};
}