Skip to content

Commit

Permalink
Package: Add repositoryName
Browse files Browse the repository at this point in the history
  • Loading branch information
dmstern committed Aug 27, 2018
1 parent 326ef2e commit 2dd1aef
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/model/Package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export default class Package implements PackageMetaDataDTO {
public readonly dependenciesCount: number;
public readonly scope: string | undefined;
public readonly mainCode: string | undefined;
protected repositoryNameIsBeautified: boolean = false;

constructor(packageMetaData: PackageMetaDataDTO) {
Object.assign(this, packageMetaData);
Expand Down Expand Up @@ -101,4 +102,18 @@ export default class Package implements PackageMetaDataDTO {
}
}

public get repositoryName() {
if (this.repositoryUrl) {
if (this.repositoryUrl.includes('github')) {
this.repositoryNameIsBeautified = true;
return 'github';
}
if (this.repositoryUrl.includes('gitlab')) {
this.repositoryNameIsBeautified = true;
return 'gitlab';
}
return this.repositoryUrl.split('/')[2];
}
}

}

0 comments on commit 2dd1aef

Please sign in to comment.