From 47d98f7b548927dc170d81d0e468a0888308f19b Mon Sep 17 00:00:00 2001 From: Michael Wu Date: Tue, 11 Jul 2017 08:34:09 -0700 Subject: [PATCH] Fix paging infinite loop (#12) Previously would BranchManager would correctly parse the link header but fail to update the request options object, resulting in an infinite loop when a next link is present. --- src/branch-manager/branchManager.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/branch-manager/branchManager.ts b/src/branch-manager/branchManager.ts index 000bd42..9ad2634 100644 --- a/src/branch-manager/branchManager.ts +++ b/src/branch-manager/branchManager.ts @@ -156,7 +156,7 @@ export class BranchManager { if (protectedBranchesOnly) { uri = uri.concat("?protected=true"); } - const requestOptions = this.getDefaultRequestOptions(uri); + let requestOptions = this.getDefaultRequestOptions(uri); let branches: IBranch[] = []; do { this.logger.debug(`GET ${uri}`); @@ -171,6 +171,9 @@ export class BranchManager { } this.logger.debug(`Got link header: ${maybeLinkHeader}`); uri = this.getNextLink(maybeLinkHeader as string); + if (uri !== undefined) { + requestOptions = this.getDefaultRequestOptions(uri); + } } catch (error) { throw error; }