From 7984f29aaad437389fdaeb4dd4a1925b39e2a5dc Mon Sep 17 00:00:00 2001 From: hwen Date: Mon, 17 Jul 2023 18:22:50 +0800 Subject: [PATCH] :lipstick: --- src/publicApi.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/publicApi.ts b/src/publicApi.ts index a9834af5..853c84a8 100644 --- a/src/publicApi.ts +++ b/src/publicApi.ts @@ -307,7 +307,9 @@ export function rawWorkspaceToWorkspaceData(rawWorkspaces: Workspace): Workspace export function rawWorkspaceToWorkspaceData(rawWorkspaces: Workspace[]): WorkspaceData[]; export function rawWorkspaceToWorkspaceData(rawWorkspaces: Workspace | Workspace[]) { const toWorkspaceData = (ws: Workspace) => { - const contextUrl = ws.context?.details.case === 'git' ? ws.context.details.value.normalizedContextUrl : ws.context.contextUrl; + // https://github.com/gitpod-io/gitpod/blob/7e0c605a3d470b8cee0e841e51da9b20022f4f4b/components/public-api-server/pkg/apiv1/workspace.go#L332-L335 + // it's always git context, safe to go + const contextUrl = ws.context?.details.case === 'git' ? ws.context.details.value.normalizedContextUrl : ws.context!.contextUrl; const url = new URL(contextUrl); const provider = url.host.replace(/\..+?$/, ''); // remove '.com', etc const matches = url.pathname.match(/[^/]+/g)!; // match /owner/repo