Resolved PR feedback
Signed-off-by: Bart Breen <bart.breen@twobulls.com>
This commit is contained in:
+2
-2
@@ -99,8 +99,8 @@ function setupBitbucketCloudStubs(
|
||||
server.use(
|
||||
rest.get(
|
||||
`https://api.bitbucket.org/2.0/repositories/${workspace}`,
|
||||
(_, res, ctx) => {
|
||||
stubCallerFn(_);
|
||||
(req, res, ctx) => {
|
||||
stubCallerFn(req);
|
||||
return res(
|
||||
ctx.json(
|
||||
pagedResponse(
|
||||
|
||||
@@ -246,8 +246,7 @@ function parseUrl(urlString: string): {
|
||||
|
||||
function readPathParameters(pathParts: string[]): Map<string, string> {
|
||||
const vals: Record<string, any> = {};
|
||||
for (let i = 0; i < pathParts.length; i += 2) {
|
||||
if (i + 1 >= pathParts.length) continue;
|
||||
for (let i = 0; i + 1 < pathParts.length; i += 2) {
|
||||
vals[pathParts[i]] = decodeURIComponent(pathParts[i + 1]);
|
||||
}
|
||||
return new Map<string, string>(Object.entries(vals));
|
||||
|
||||
@@ -37,7 +37,7 @@ export class BitbucketClient {
|
||||
options?: ListOptions20,
|
||||
): Promise<PagedResponse20<BitbucketRepository20>> {
|
||||
return this.pagedRequest20<BitbucketRepository20>(
|
||||
`${this.config.apiBaseUrl}/repositories/${workspace}`,
|
||||
`${this.config.apiBaseUrl}/repositories/${encodeURIComponent(workspace)}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
@@ -47,7 +47,9 @@ export class BitbucketClient {
|
||||
options?: ListOptions,
|
||||
): Promise<PagedResponse<any>> {
|
||||
return this.pagedRequest(
|
||||
`${this.config.apiBaseUrl}/projects/${projectKey}/repos`,
|
||||
`${this.config.apiBaseUrl}/projects/${encodeURIComponent(
|
||||
projectKey,
|
||||
)}/repos`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
@@ -74,9 +76,7 @@ export class BitbucketClient {
|
||||
} - ${response.statusText}`,
|
||||
);
|
||||
}
|
||||
return response.json().then(repositories => {
|
||||
return repositories as PagedResponse<any>;
|
||||
});
|
||||
return response.json() as Promise<PagedResponse<any>>;
|
||||
}
|
||||
|
||||
private async pagedRequest20<T = any>(
|
||||
@@ -101,9 +101,7 @@ export class BitbucketClient {
|
||||
} - ${response.statusText}`,
|
||||
);
|
||||
}
|
||||
return response.json().then(repositories => {
|
||||
return repositories as PagedResponse20<T>;
|
||||
});
|
||||
return response.json() as Promise<PagedResponse20<T>>;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user