-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Saku Laitinen
committed
Jan 11, 2017
1 parent
9281ab1
commit 6b4d877
Showing
3 changed files
with
54 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,16 +18,33 @@ function find(array, predicate) { | |
} | ||
} | ||
|
||
function findHandler(handlers, method, url, body) { | ||
function findHandler(handlers, method, url, body, parameters) { | ||
return find(handlers[method.toLowerCase()], function(handler) { | ||
if (typeof handler[0] === 'string') { | ||
return url === handler[0] && isBodyMatching(body, handler[1]); | ||
return url === handler[0] && isBodyOrParametersMatching(method, body, parameters, handler[1]); | ||
} else if (handler[0] instanceof RegExp) { | ||
return handler[0].test(url) && isBodyMatching(body, handler[1]); | ||
return handler[0].test(url) && isBodyOrParametersMatching(method, body, parameters, handler[1]); | ||
} | ||
}); | ||
} | ||
|
||
function isBodyOrParametersMatching(method, body, parameters, required) { | ||
This comment has been minimized.
Sorry, something went wrong.
signal-intrusion
|
||
if (method === 'get') { | ||
var params = required ? required.params : undefined; | ||
return isParametersMatching(parameters, params); | ||
} else { | ||
return isBodyMatching(body, required); | ||
} | ||
} | ||
|
||
function isParametersMatching(parameters, required) { | ||
if (required === undefined && parameters === undefined) { | ||
return true; | ||
} | ||
|
||
return isEqual(parameters, required); | ||
} | ||
|
||
function isBodyMatching(body, requiredBody) { | ||
if (requiredBody === undefined) { | ||
return true; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Thank you guys, you broke our tests, you merged this shit even without changing version of npm-package.
axios supports empty object {} for parameters