Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion packages/desktop-electron/src/main/ipc.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { execFile } from "node:child_process"
import { BrowserWindow, Notification, app, clipboard, dialog, ipcMain, shell } from "electron"
import * as path from "node:path"
import type { IpcMainEvent, IpcMainInvokeEvent } from "electron"

import type { InitStep, ServerReadyData, SqliteMigrationProgress, TitlebarTheme, WslConfig } from "../preload/types"
Expand Down Expand Up @@ -127,7 +128,16 @@ export function registerIpcHandlers(deps: Deps) {
)

ipcMain.on("open-link", (_event: IpcMainEvent, url: string) => {
void shell.openExternal(url)
// Convert local file paths to file:// URLs
// If the URL doesn't have a scheme (not http://, https://, file://, etc.),
// treat it as a local file path and convert to file://
let finalUrl = url
if (!url.match(/^[a-zA-Z][a-zA-Z\d+.-]*:/)) {
// Resolve relative paths to absolute paths
const absolutePath = path.resolve(url)
finalUrl = `file://${absolutePath}`
}
void shell.openExternal(finalUrl)
})

ipcMain.handle("open-path", async (_event: IpcMainInvokeEvent, path: string, app?: string) => {
Expand Down
Loading