From 0fa6c33c44e92d0d1729d3d557d02ac7db87e73f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20H=C3=A4usler?= Date: Wed, 30 Dec 2020 10:49:33 +0100 Subject: [PATCH] Fix unable to open URL (#2453) --- src/main/menu/actions/file.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/menu/actions/file.js b/src/main/menu/actions/file.js index 37acc273..fd892c7e 100644 --- a/src/main/menu/actions/file.js +++ b/src/main/menu/actions/file.js @@ -409,19 +409,20 @@ ipcMain.on('mt::ask-for-open-project-in-sidebar', async e => { }) ipcMain.on('mt::format-link-click', (e, { data, dirname }) => { - if (!data || !data.href || typeof data.href !== 'string') { + if (!data || (!data.href && !data.text)) { return } - if (URL_REG.test(data.href)) { - return shell.openExternal(data.href) + const href = data.href || data.text + if (URL_REG.test(href)) { + return shell.openExternal(href) } + let pathname = null - if (path.isAbsolute(data.href) && isMarkdownFile(data.href)) { - pathname = data.href - } - if (!path.isAbsolute(data.href) && isMarkdownFile(path.join(dirname, data.href))) { - pathname = path.join(dirname, data.href) + if (path.isAbsolute(href) && isMarkdownFile(href)) { + pathname = href + } else if (!path.isAbsolute(href) && isMarkdownFile(path.join(dirname, href))) { + pathname = path.join(dirname, href) } if (pathname) { const win = BrowserWindow.fromWebContents(e.sender)