mirror of
https://github.com/cypress-io/cypress.git
synced 2026-01-19 13:39:56 -06:00
23 lines
502 B
JavaScript
23 lines
502 B
JavaScript
const contentType = require('content-type')
|
|
|
|
module.exports = {
|
|
getContentType (res) {
|
|
try {
|
|
return contentType.parse(res).type
|
|
} catch (err) {
|
|
// https://github.com/cypress-io/cypress/issues/3101
|
|
return res.headers['content-type']
|
|
}
|
|
},
|
|
|
|
hasContentType (res, type) {
|
|
// does the response object have a content-type
|
|
// that matches what we expect
|
|
try {
|
|
return contentType.parse(res).type === type
|
|
} catch (err) {
|
|
return false
|
|
}
|
|
},
|
|
}
|