From a3baf41237a2617124d8fa84afcc50875b48670e Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sun, 14 Aug 2022 15:15:28 -0400 Subject: [PATCH] *Handle both google.com and www.google.com *Ensure queriedUrl has a protocol before parsing *Handle kernel.skynet in navigation request *Abort if we are not logged in only after checking for kernel urls --- src/main/background.ts | 1 - src/webEngine.ts | 24 +++++++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/main/background.ts b/src/main/background.ts index 21960e9..b91ed2f 100644 --- a/src/main/background.ts +++ b/src/main/background.ts @@ -206,7 +206,6 @@ async function boot() { engine.registerContentProvider(new SkynetProvider(engine)); engine.registerContentProvider(new IpfsProvider(engine)); - // @ts-ignore setKernelIframe(document.createElement("iframe")); getKernelIframe().src = "http://kernel.skynet"; getKernelIframe().onload = init; diff --git a/src/webEngine.ts b/src/webEngine.ts index 5baded8..e3c8d51 100644 --- a/src/webEngine.ts +++ b/src/webEngine.ts @@ -203,13 +203,7 @@ export default class WebEngine { return; } - if ("kernel.skynet" === hostname) { - return; - } - if (getAuthStatus().loginComplete !== true) { - return; - } - if ("google.com" !== hostname) { + if (!["google.com", "www.google.com"].includes(hostname)) { return; } if ( @@ -222,6 +216,9 @@ export default class WebEngine { } let queriedUrl = originalUrl.searchParams.get("q") as string; + if (!queriedUrl.includes("://")) { + queriedUrl = `http://${queriedUrl}`; + } let queriedHost = queriedUrl; try { let queriedUrlUbj = new URL(queriedUrl); @@ -250,6 +247,19 @@ export default class WebEngine { this.navigations.set(this.getNavigationId(details), promise); + if ("kernel.skynet" === queriedHost) { + if (!queriedUrl.includes("://")) { + queriedUrl = `http://${queriedUrl}`; + } + rejectRequest(queriedUrl); + return; + } + + if (getAuthStatus().loginComplete !== true) { + resolveRequest(); + return; + } + try { dns = await resolve(queriedHost, {}); } catch (e) {