Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
Merge ec73aa9 into c0c32f7
Browse files Browse the repository at this point in the history
  • Loading branch information
techstonia authored Jan 9, 2019
2 parents c0c32f7 + ec73aa9 commit 6427bbc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions lib/hock.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,11 @@ class Hock {
* @returns {Hock}
*/
filteringRequestBodyRegEx(source, replace) {
this._requestFilter = function(path) {
if (path) {
path = path.replace(source, replace);
this._requestFilter = function({body}) {
if (body) {
body = body.replace(source, replace);
}
return path;
return body;
};

return this;
Expand Down
2 changes: 1 addition & 1 deletion lib/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ module.exports = class Request {
}
else {
if (this._parent._requestFilter) {
request.body = this._parent._requestFilter(request.body);
request.body = this._parent._requestFilter(request);
}

return this.method === request.method && this.url === request.url &&
Expand Down
3 changes: 2 additions & 1 deletion test/simple-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,9 @@ describe('Hock HTTP Tests', function() {

it('should correctly use functions', function(done) {
this.hockInstance
.filteringRequestBody(function(body) {
.filteringRequestBody(function({body, url}) {
expect(body).toEqual(JSON.stringify({numbers: '123'}));
expect(url).toEqual("/post");
return JSON.stringify({numbers: 'numbers-stripped'});
})
.post('/post', { numbers: 'numbers-stripped' })
Expand Down

0 comments on commit 6427bbc

Please sign in to comment.