Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update desktop app to support new org urls (desktop app update) #170

Merged
merged 2 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ export const isLoadingProdReplit = baseUrl === defaultBaseUrl;
// Matches /@:username/:slug
export const personalReplUrlRegex = /^\/@([^/#?]+?)(?:\/([^/#?]+?))[/#?]?$/i;
// Matches /t/:orgSlug/:orgId/repls/:replSlug
export const teamReplUrlRegex =
export const legacyTeamReplUrlRegex =
/^\/t(?:\/([^/#?]+?))(?:\/([^/#?]+?))\/repls(?:\/([^/#?]+?))[/#?]?$/i;
// Matches /t/:orgSlug/:orgId/repls/:replSlug
export const teamReplUrlRegex =
/^\/t(?:\/([^/#?]+?))\/repls(?:\/([^/#?]+?))[/#?]?$/i;

export const homePage = '/desktopApp/home';
export const authPage = '/desktopApp/auth';
Expand Down
4 changes: 3 additions & 1 deletion src/createWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
personalReplUrlRegex,
homePage,
isProduction,
legacyTeamReplUrlRegex,
} from './constants';
import log from 'electron-log/main';
import { events } from './events';
Expand Down Expand Up @@ -57,7 +58,8 @@ function setLastOpenRepl(url: string, lastOpenRepl: string | null) {

if (
!personalReplUrlRegex.test(u.pathname) &&
!teamReplUrlRegex.test(u.pathname)
!teamReplUrlRegex.test(u.pathname) &&
!legacyTeamReplUrlRegex.test(u.pathname)
) {
return;
}
Expand Down
7 changes: 6 additions & 1 deletion src/deeplink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
semverRegex,
authPage,
homePage,
legacyTeamReplUrlRegex,
} from './constants';
import path from 'path';
import { createWindow } from './createWindow';
Expand Down Expand Up @@ -128,7 +129,11 @@ function handleNew(language: string) {
}

function handleRepl(url: string) {
if (!personalReplUrlRegex.test(url) && !teamReplUrlRegex.test(url)) {
if (
!personalReplUrlRegex.test(url) &&
!teamReplUrlRegex.test(url) &&
!legacyTeamReplUrlRegex.test(url)
) {
log.error('Expected valid workspace URL');

return;
Expand Down
2 changes: 2 additions & 0 deletions src/isSupportedPage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
desktopAppPrefix,
legacyTeamReplUrlRegex,
personalReplUrlRegex,
teamReplUrlRegex,
} from './constants';
Expand All @@ -11,6 +12,7 @@ export default function isSupportedPage(page: string): boolean {
page.startsWith(desktopAppPrefix) ||
personalReplUrlRegex.test(page) ||
teamReplUrlRegex.test(page) ||
legacyTeamReplUrlRegex.test(page) ||
supportedNonDesktopAppPages.includes(page)
);
}
Loading