mirror of
https://github.com/marktext/marktext.git
synced 2025-05-02 11:20:25 +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 }) => {
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user