diff --git a/src/ipc/handlers/app_handlers.ts b/src/ipc/handlers/app_handlers.ts index 590b789..fa13563 100644 --- a/src/ipc/handlers/app_handlers.ts +++ b/src/ipc/handlers/app_handlers.ts @@ -1202,6 +1202,20 @@ export function registerAppHandlers() { throw new Error("App not found"); } + const pathChanged = appPath !== app.path; + + if (pathChanged) { + const invalidChars = /[<>:"|?*\/\\]/; + const hasInvalidChars = + invalidChars.test(appPath) || /[\x00-\x1f]/.test(appPath); + + if (hasInvalidChars) { + throw new Error( + `App path "${appPath}" contains characters that are not allowed in folder names: < > : " | ? * / \\ or control characters. Please use a different path.`, + ); + } + } + // Check for conflicts with existing apps const nameConflict = await db.query.apps.findFirst({ where: eq(apps.name, appName), diff --git a/src/pages/app-details.tsx b/src/pages/app-details.tsx index b6a3238..a2fffdf 100644 --- a/src/pages/app-details.tsx +++ b/src/pages/app-details.tsx @@ -128,11 +128,10 @@ export default function AppDetailsPage() { await refreshApps(); } catch (error) { console.error("Failed to rename app:", error); - alert( - `Error renaming app: ${ - error instanceof Error ? error.message : String(error) - }`, - ); + const errorMessage = ( + error instanceof Error ? error.message : String(error) + ).replace(/^Error invoking remote method 'rename-app': Error: /, ""); + showError(errorMessage); } finally { setIsRenaming(false); } @@ -143,7 +142,6 @@ export default function AppDetailsPage() { try { setIsRenamingFolder(true); - await IpcClient.getInstance().renameApp({ appId, appName: selectedApp.name, // Keep the app name the same @@ -154,11 +152,10 @@ export default function AppDetailsPage() { await refreshApps(); } catch (error) { console.error("Failed to rename folder:", error); - alert( - `Error renaming folder: ${ - error instanceof Error ? error.message : String(error) - }`, - ); + const errorMessage = ( + error instanceof Error ? error.message : String(error) + ).replace(/^Error invoking remote method 'rename-app': Error: /, ""); + showError(errorMessage); } finally { setIsRenamingFolder(false); }