Yuki Takei 2 lat temu
rodzic
commit
4308d3018d

+ 14 - 1
apps/app/src/features/growi-plugin/models/vo/github-url.spec.ts

@@ -17,7 +17,7 @@ describe('GitHubUrl Constructor throws an error when the url string is', () => {
 
 });
 
-describe('GitHubUrl Constructor is successfully processed', () => {
+describe('The constructor is successfully processed', () => {
 
   it('with http schemed url', () => {
     // when
@@ -53,3 +53,16 @@ describe('GitHubUrl Constructor is successfully processed', () => {
   });
 
 });
+
+describe('archiveUrl()', () => {
+  it('returns zip url', () => {
+    // setup
+    const githubUrl = new GitHubUrl('https://github.com/org/repos', 'fix/bug');
+
+    // when
+    const { archiveUrl } = githubUrl;
+
+    // then
+    expect(archiveUrl).toEqual('https://github.com/org/repos/archive/refs/heads/fix/bug.zip');
+  });
+});

+ 5 - 0
apps/app/src/features/growi-plugin/models/vo/github-url.ts

@@ -21,6 +21,11 @@ export class GitHubUrl {
     return this._branchName;
   }
 
+  get archiveUrl(): string {
+    const ghUrl = new URL(`/${this.organizationName}/${this.reposName}/archive/refs/heads/${this.branchName}.zip`, 'https://github.com');
+    return ghUrl.toString();
+  }
+
   constructor(url: string, branchName = 'main') {
 
     let matched;