Skip to content

Commit

Permalink
Update project value
Browse files Browse the repository at this point in the history
  • Loading branch information
mustard-mh committed Nov 14, 2023
1 parent d297e91 commit aa4fb35
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion components/dashboard/src/workspaces/WorkspaceEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,15 @@ export const WorkspaceEntry: FunctionComponent<Props> = ({ info, shortVersion })
};

export function getProjectPath(ws: Workspace) {
return ws.contextUrl;
if (!ws.status?.gitStatus?.cloneUrl) {
return ws.contextUrl.replace("https://", "");
}
// http[s]?:\/\/(?<project>.*?\/.*?\/.*?)[./]
const regex = /http[s]?:\/\/(?<host>.*?)\/(?<owner>.*?)\/(?<name>.*?)[./]/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}`;
}

0 comments on commit aa4fb35

Please sign in to comment.