From f6398a1fb50c4b0ba7266e0e9b5f92b2f9c1ae2d Mon Sep 17 00:00:00 2001 From: sergeichestakov Date: Thu, 10 Aug 2023 11:06:40 -0400 Subject: [PATCH] Add support for deeplinks to home page --- src/deeplink.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/deeplink.ts b/src/deeplink.ts index 83bd928..0f2c0e5 100644 --- a/src/deeplink.ts +++ b/src/deeplink.ts @@ -6,6 +6,7 @@ import { workspaceUrlRegex, semverRegex, authPage, + homePage, } from "./constants"; import path from "path"; import { createWindow } from "./createWindow"; @@ -41,6 +42,12 @@ function handleDeeplink(deeplink: string): void { break; } + case "home": { + handleHome(); + + break; + } + case "repl": { handleRepl(url.pathname); @@ -53,6 +60,22 @@ function handleDeeplink(deeplink: string): void { } } +function handleHome() { + const homeUrl = `${baseUrl}${homePage}`; + + const focused = BrowserWindow.getFocusedWindow(); + + if (focused) { + focused.loadURL(homeUrl); + + return; + } + + createWindow({ + url: homeUrl, + }); +} + function handleRepl(url: string) { if (!workspaceUrlRegex.test(url)) { console.error("Expected URL of the format /@username/slug");