From 572ed9ee867370c80cf5bb7831363eca30a3cef4 Mon Sep 17 00:00:00 2001 From: ekoster1 <48770483+ekoster1@users.noreply.github.com> Date: Wed, 22 Dec 2021 15:21:18 -0600 Subject: [PATCH] Open non-markdown files in default application #2396 (#2563) --- src/main/menu/actions/file.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/menu/actions/file.js b/src/main/menu/actions/file.js index fd892c7e..634d0eb2 100644 --- a/src/main/menu/actions/file.js +++ b/src/main/menu/actions/file.js @@ -419,14 +419,17 @@ ipcMain.on('mt::format-link-click', (e, { data, dirname }) => { } let pathname = null - if (path.isAbsolute(href) && isMarkdownFile(href)) { + if (path.isAbsolute(href)) { pathname = href - } else if (!path.isAbsolute(href) && isMarkdownFile(path.join(dirname, href))) { + } else if (dirname && !path.isAbsolute(href)) { pathname = path.join(dirname, href) } - if (pathname) { + + if (pathname && isMarkdownFile(pathname)) { const win = BrowserWindow.fromWebContents(e.sender) return openFileOrFolder(win, pathname) + } else if (pathname) { + return shell.openPath(pathname) } })