This commit is contained in:
xuziqiang
2024-05-15 17:29:42 +08:00
commit d0155dbe3c
7296 changed files with 1832517 additions and 0 deletions

15
lib/use/use-path.ts Normal file
View File

@@ -0,0 +1,15 @@
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,
};
}