Skip to content

Commit

Permalink
💄
Browse files Browse the repository at this point in the history
  • Loading branch information
mustard-mh committed Jul 17, 2023
1 parent 3070a32 commit 7984f29
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/publicApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7984f29

Please sign in to comment.