diff --git a/packages/backend-common/src/reading/GithubUrlReader.test.ts b/packages/backend-common/src/reading/GithubUrlReader.test.ts index eb87d339ea..abe8b4f640 100644 --- a/packages/backend-common/src/reading/GithubUrlReader.test.ts +++ b/packages/backend-common/src/reading/GithubUrlReader.test.ts @@ -235,6 +235,40 @@ describe('GithubUrlReader', () => { expect(indexMarkdownFile.toString()).toBe('# Test\n'); }); + it('includes the subdomain in the github url', async () => { + worker.resetHandlers(); + worker.use( + rest.get( + 'https://ghe.github.com/backstage/mock/archive/repo.tar.gz', + (_, res, ctx) => + res( + ctx.status(200), + ctx.set('Content-Type', 'application/x-gzip'), + ctx.body(repoBuffer), + ), + ), + ); + + const processor = new GithubUrlReader( + { + host: 'ghe.github.com', + apiBaseUrl: 'https://api.github.com', + }, + { treeResponseFactory }, + ); + + const response = await processor.readTree( + 'https://ghe.github.com/backstage/mock/tree/repo/docs', + ); + + const files = await response.files(); + + expect(files.length).toBe(1); + const indexMarkdownFile = await files[0].content(); + + expect(indexMarkdownFile.toString()).toBe('# Test\n'); + }); + it('must specify a branch', async () => { const processor = new GithubUrlReader( { diff --git a/packages/backend-common/src/reading/GithubUrlReader.ts b/packages/backend-common/src/reading/GithubUrlReader.ts index 907f2ada7a..692a3c6dd8 100644 --- a/packages/backend-common/src/reading/GithubUrlReader.ts +++ b/packages/backend-common/src/reading/GithubUrlReader.ts @@ -179,7 +179,7 @@ export class GithubUrlReader implements UrlReader { name: repoName, ref, protocol, - source, + resource, full_name, filepath, } = parseGitUri(url); @@ -194,7 +194,7 @@ export class GithubUrlReader implements UrlReader { // TODO(Rugvip): use API to fetch URL instead const response = await fetch( new URL( - `${protocol}://${source}/${full_name}/archive/${ref}.tar.gz`, + `${protocol}://${resource}/${full_name}/archive/${ref}.tar.gz`, ).toString(), ); if (!response.ok) {