You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
316 B
16 lines
316 B
6 months ago
|
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,
|
||
|
};
|
||
|
}
|