16 lines
370 B
TypeScript
16 lines
370 B
TypeScript
const resolveEditorPath = (editorPath: string[] = []) => {
|
|
const hasPath = editorPath.length > 0;
|
|
|
|
const isEdit = hasPath ? editorPath[editorPath.length - 1] === "edit" : false;
|
|
|
|
return {
|
|
isEdit,
|
|
path: `/${(isEdit
|
|
? [...editorPath].slice(0, editorPath.length - 1)
|
|
: [...editorPath]
|
|
).join("/")}`,
|
|
};
|
|
};
|
|
|
|
export default resolveEditorPath;
|