Skip to content

Commit

Permalink
Merge pull request #3007 from cloudfoundry-incubator/git-diagnostics-fix
Browse files Browse the repository at this point in the history
Diagnostics does not show GitHub details when cloned via HTTPS
  • Loading branch information
richard-cox authored Sep 17, 2018
2 parents 02057f5 + f1c527f commit 6350c84
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,17 @@ export class DiagnosticsPageComponent implements OnInit {
}

private getGitHubProject(prj: string): string {
const parts = prj.split(':');
if (parts.length === 2 && parts[0].indexOf('@github.com') >= 0) {
return parts[1];
let projectUrl = prj;
// Remove trailing .git if it is there
if (projectUrl.endsWith('.git')) {
projectUrl = projectUrl.substr(0, projectUrl.length - 4);
}

// Handle either SSH or HTTPS GitHub URLs
if (projectUrl.toLowerCase().startsWith('git@github.com:')) {
return projectUrl.substr(15);
} else if (projectUrl.toLowerCase().startsWith('https://github.com/')) {
return projectUrl.substr(19);
}
return '';
}
Expand Down

0 comments on commit 6350c84

Please sign in to comment.