Merge pull request #28453 from Andrzejewski-dev/master

chore: update getFile in BitbucketServerClient to use REST API path
This commit is contained in:
Ben Lambert
2025-01-14 08:21:53 +01:00
committed by GitHub
3 changed files with 7 additions and 3 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-backend-module-bitbucket-server': patch
---
Updated the `getFile` method in `BitbucketServerClient` to use `this.config.apiBaseUrl` directly for constructing the API request URL, removing the creation of an unnecessary `URL` object. The method now relies on REST API paths for accessing resources instead of direct access, ensuring better alignment with Bitbucket's API conventions.
@@ -153,7 +153,7 @@ describe('BitbucketServerClient', () => {
it('getFile', async () => {
server.use(
rest.get(
`https://${config.host}/projects/test-project/repos/test-repo/raw/catalog-info.yaml`,
`${config.apiBaseUrl}/projects/test-project/repos/test-repo/raw/catalog-info.yaml`,
(req, res, ctx) => {
if (
req.headers.get('authorization') !==
@@ -77,9 +77,8 @@ export class BitbucketServerClient {
repo: string;
path: string;
}): Promise<Response> {
const base = new URL(this.config.apiBaseUrl);
return throttledFetch(
`${base.protocol}//${base.host}/projects/${options.projectKey}/repos/${options.repo}/raw/${options.path}`,
`${this.config.apiBaseUrl}/projects/${options.projectKey}/repos/${options.repo}/raw/${options.path}`,
getBitbucketServerRequestOptions(this.config),
);
}