diff --git a/components/dashboard/src/workspaces/WorkspaceEntry.tsx b/components/dashboard/src/workspaces/WorkspaceEntry.tsx index 8b4e9be48f8e8c..5bda904790b9b8 100644 --- a/components/dashboard/src/workspaces/WorkspaceEntry.tsx +++ b/components/dashboard/src/workspaces/WorkspaceEntry.tsx @@ -104,5 +104,15 @@ export const WorkspaceEntry: FunctionComponent = ({ info, shortVersion }) }; export function getProjectPath(ws: Workspace) { - return ws.contextUrl; + if (!ws.status?.gitStatus?.cloneUrl) { + return ws.contextUrl.replace("https://", ""); + } + // http[s]?:\/\/(?.*?\/.*?\/.*?)[./] + const regex = /http[s]?:\/\/(?.*?)\/(?.*?)\/(?.*?)[./]/gm; + const result = regex.exec(ws.status.gitStatus.cloneUrl); + if (!result) { + return ws.contextUrl.replace("https://", ""); + } + const { host, owner, name } = result.groups!; + return `${host}/${owner}/${name}`; }