mirror of
https://github.com/marktext/marktext.git
synced 2025-05-02 23:43:41 +08:00
Fix unable to open URL (#2453)
This commit is contained in:
parent
cb38f99d2d
commit
0fa6c33c44
@ -409,19 +409,20 @@ ipcMain.on('mt::ask-for-open-project-in-sidebar', async e => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.on('mt::format-link-click', (e, { data, dirname }) => {
|
ipcMain.on('mt::format-link-click', (e, { data, dirname }) => {
|
||||||
if (!data || !data.href || typeof data.href !== 'string') {
|
if (!data || (!data.href && !data.text)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (URL_REG.test(data.href)) {
|
const href = data.href || data.text
|
||||||
return shell.openExternal(data.href)
|
if (URL_REG.test(href)) {
|
||||||
|
return shell.openExternal(href)
|
||||||
}
|
}
|
||||||
|
|
||||||
let pathname = null
|
let pathname = null
|
||||||
if (path.isAbsolute(data.href) && isMarkdownFile(data.href)) {
|
if (path.isAbsolute(href) && isMarkdownFile(href)) {
|
||||||
pathname = data.href
|
pathname = href
|
||||||
}
|
} else if (!path.isAbsolute(href) && isMarkdownFile(path.join(dirname, href))) {
|
||||||
if (!path.isAbsolute(data.href) && isMarkdownFile(path.join(dirname, data.href))) {
|
pathname = path.join(dirname, href)
|
||||||
pathname = path.join(dirname, data.href)
|
|
||||||
}
|
}
|
||||||
if (pathname) {
|
if (pathname) {
|
||||||
const win = BrowserWindow.fromWebContents(e.sender)
|
const win = BrowserWindow.fromWebContents(e.sender)
|
||||||
|
Loading…
Reference in New Issue
Block a user