Skip to content

Commit bd14a83

Browse files
committed
Use ContextURL to parse getProjectPath
1 parent 3247ee9 commit bd14a83

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

components/dashboard/src/workspaces/WorkspaceEntry.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import dayjs from "dayjs";
1313
import { WorkspaceEntryOverflowMenu } from "./WorkspaceOverflowMenu";
1414
import { WorkspaceStatusIndicator } from "./WorkspaceStatusIndicator";
1515
import { Workspace } from "@gitpod/public-api/lib/gitpod/v1/workspace_pb";
16+
import { ContextURL } from "@gitpod/gitpod-protocol";
1617

1718
type Props = {
1819
info: Workspace;
@@ -104,15 +105,11 @@ export const WorkspaceEntry: FunctionComponent<Props> = ({ info, shortVersion })
104105
};
105106

106107
export function getProjectPath(ws: Workspace) {
107-
if (!ws.status?.gitStatus?.cloneUrl) {
108+
// we don't need to provide context here, only contextURL is needed
109+
// TODO: Remove and call papi ContextService
110+
const url = ContextURL.getNormalizedURL({ context: { title: ws.name }, contextURL: ws.contextUrl });
111+
if (!url) {
108112
return ws.contextUrl.replace("https://", "");
109113
}
110-
// http[s]?:\/\/(?<project>.*?\/.*?\/.*?)[./]
111-
const regex = /http[s]?:\/\/(?<host>.*?)\/(?<owner>.*?)\/(?<name>.*?)[./]/gm;
112-
const result = regex.exec(ws.status.gitStatus.cloneUrl);
113-
if (!result) {
114-
return ws.contextUrl.replace("https://", "");
115-
}
116-
const { host, owner, name } = result.groups!;
117-
return `${host}/${owner}/${name}`;
114+
return [url.host, url.pathname].join("/");
118115
}

0 commit comments

Comments
 (0)