From 75274a02307b76cce7073f5e3064f8f392d8d8dc Mon Sep 17 00:00:00 2001 From: Juan Cazala Date: Tue, 7 Jan 2025 18:55:41 -0300 Subject: [PATCH] fix: make custom items path prettier (#357) --- packages/renderer/src/modules/rpc/index.ts | 10 +++++++--- packages/shared/paths.ts | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/renderer/src/modules/rpc/index.ts b/packages/renderer/src/modules/rpc/index.ts index 01ecc62..9ec38b7 100644 --- a/packages/renderer/src/modules/rpc/index.ts +++ b/packages/renderer/src/modules/rpc/index.ts @@ -23,12 +23,16 @@ interface Callbacks { ) => Promise; } -const getPath = async (path: string, project: Project) => { +const getPath = async (filePath: string, project: Project) => { let basePath = project.path; - if (path === 'custom' || path.startsWith('custom/')) { + const normalizedPath = filePath.replace(/\\/g, '/'); + if (normalizedPath === 'custom' || normalizedPath.startsWith('custom/')) { basePath = await custom.getPath(); + filePath = + normalizedPath === 'custom' ? '' : normalizedPath.substring(normalizedPath.indexOf('/') + 1); } - return await fs.resolve(basePath, path); + const resolvedPath = await fs.resolve(basePath, filePath); + return resolvedPath; }; export function initRpc(iframe: HTMLIFrameElement, project: Project, cbs: Partial = {}) { diff --git a/packages/shared/paths.ts b/packages/shared/paths.ts index 66be99e..62235db 100644 --- a/packages/shared/paths.ts +++ b/packages/shared/paths.ts @@ -1,3 +1,3 @@ export const SCENES_DIRECTORY = 'Scenes'; export const SETTINGS_DIRECTORY = 'Settings'; -export const CUSTOM_ASSETS_DIRECTORY = 'Custom'; +export const CUSTOM_ASSETS_DIRECTORY = 'Custom Items';