toxy
Version:
Hackable HTTP proxy to simulate server failure scenarios and network conditions
18 lines (13 loc) • 307 B
JavaScript
const isRegExp = require('./is-regexp')
module.exports = function matchBody (body, match) {
if (typeof match === 'function') {
return match(body)
}
if (typeof match === 'string') {
return !!~body.indexOf(match)
}
if (isRegExp(match)) {
return match.test(body)
}
return false
}