push
This commit is contained in:
15
lib/use/use-path.ts
Normal file
15
lib/use/use-path.ts
Normal 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,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user