Skip to content
This repository has been archived by the owner on Apr 20, 2019. It is now read-only.

Commit

Permalink
Fixed Bug where in a pipelined request, if the response of n'th reque…
Browse files Browse the repository at this point in the history
…st is needed by any other request where n > 9, i.e. a single digit number, it will work as expected.
  • Loading branch information
adisingh007 committed Sep 14, 2018
1 parent c325841 commit 826e5e5
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/batch.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ internals.buildPath = function (resultsData, pos, parts) {

internals.payloadRegex = /^\$(\d+)(?:\.([^\s\$]*))?/;

internals.requestRegex = /(?:\/)(?:\$(\d)+\.)?([^\/\$]*)/g;
internals.requestRegex = /(?:\/)(?:\$(\d+)\.)?([^\/\$]*)/g;

internals.parsePayload = function (obj) {

Expand Down
62 changes: 62 additions & 0 deletions test/batch.js
Original file line number Diff line number Diff line change
Expand Up @@ -514,4 +514,66 @@ describe('Batch', () => {
expect(res[0]).to.equal(false);
expect(res[1]).to.equal(false);
});

it('Checks if pipeline requests works for a request depending on other request with index in non-single digit', async () => {

const res = await Internals.makeRequest(server, JSON.stringify({
requests: [
{
method: 'GET',
path: '/item/0'
},
{
method: 'GET',
path: '/item/1'
},
{
method: 'GET',
path: '/item/2'
},
{
method: 'GET',
path: '/item/3'
},
{
method: 'GET',
path: '/item/4'
},
{
method: 'GET',
path: '/item/5'
},
{
method: 'GET',
path: '/item/6'
},
{
method: 'GET',
path: '/item/7'
},
{
method: 'GET',
path: '/item/8'
},
{
method: 'GET',
path: '/item/9'
},
{
method: 'GET',
path: '/item/10'
},
{
method: 'GET',
path: '/item/$10.id'
}
]
}));

expect(res[0].id).to.equal('0');
expect(res[1].id).to.equal('1');
expect(res[10].id).to.equal('10');
expect(res[11].id).to.equal('10');
expect(res[11].name).to.equal('Item');
});
});

0 comments on commit 826e5e5

Please sign in to comment.