Skip to content

Commit

Permalink
Add support for deeplinks to home page (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeichestakov authored Aug 10, 2023
1 parent 9fc9513 commit 5e5db6e
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/deeplink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
workspaceUrlRegex,
semverRegex,
authPage,
homePage,
} from "./constants";
import path from "path";
import { createWindow } from "./createWindow";
Expand Down Expand Up @@ -41,6 +42,12 @@ function handleDeeplink(deeplink: string): void {
break;
}

case "home": {
handleHome();

break;
}

case "repl": {
handleRepl(url.pathname);

Expand All @@ -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");
Expand Down

0 comments on commit 5e5db6e

Please sign in to comment.