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

Fixed Bug where in a pipelined request, if the response of n'th request is needed by any other request where n > 9, i.e. a single digit number, it will work as expected. #98

Merged
merged 1 commit into from
Sep 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
});
});