From 09a86b4e78ec5d00e81f908e1355eee5831b5764 Mon Sep 17 00:00:00 2001 From: TheGoddessInari Date: Tue, 7 Dec 2021 16:56:51 -0800 Subject: [PATCH] Fix the deep link logic in WebView.js. --- app/ux/WebView.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/ux/WebView.js b/app/ux/WebView.js index 95e1b9fd..48d4c7b2 100644 --- a/app/ux/WebView.js +++ b/app/ux/WebView.js @@ -259,11 +259,13 @@ Ext.define('Hamsket.ux.WebView',{ // Open links in default browser webview.addEventListener('new-window', function (e) { e.preventDefault(); - const protocol = require('url').URL(e.url).protocol; + const { URL } = require('url'); + const url = new URL(e.url); + const protocol = url.protocol; // Block some Deep links to prevent that open its app (Ex: Slack) if (['slack:'].includes(protocol)) return; // Allow Deep links - if (!['http:', 'https:', 'about:'].includes(protocol)) return require('electron').shell.openExternal(e.url); + if (!['http:', 'https:', 'about:'].includes(protocol)) return require('electron').shell.openExternal(url.href); }); webview.addEventListener('will-navigate', function(e, url) {