Skip to content

Commit b1307db

Browse files
committed
Open external url by default browser
1 parent 0a997d5 commit b1307db

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

renderer.js

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { ipcRenderer, remote, clipboard } = require('electron')
1+
const { ipcRenderer, remote, clipboard, shell } = require('electron')
22
const { Menu } = remote
33

44
const os = remote.require('os')
@@ -35,7 +35,7 @@ window.onload = () => {
3535
targetURL = getServerUrl()
3636
}
3737

38-
document.body.innerHTML += `<webview src="${targetURL}" id="main-window" disablewebsecurity autosize="on" allowpopups allowfileaccessfromfiles></webview>`
38+
document.body.innerHTML += `<webview src="${targetURL}" id="main-window" autosize="on" allowpopups allowfileaccessfromfiles></webview>`
3939

4040
const webview = document.getElementById('main-window')
4141

@@ -203,10 +203,18 @@ window.onload = () => {
203203

204204
$('#open-from-url-modal.modal #submit-file-url').click(function () {
205205
let url = $('#open-from-url-modal.modal input[type="text"]').val()
206-
if (url.length > 0) {
206+
const serverurl = getServerUrl()
207+
if (url.length <= 0) {
208+
return
209+
}
210+
211+
if (!url.match(serverurl)) {
212+
shell.openExternal(url)
213+
} else {
207214
ipcClient('createWindow', { url: `file://${path.join(__dirname, `index.html?target=${url}`)}` })
208-
$('#open-from-url-modal.modal').modal('hide')
209215
}
216+
217+
$('#open-from-url-modal.modal').modal('hide')
210218
})
211219

212220
/* handle _target=blank pages */

0 commit comments

Comments
 (0)