You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
400 B
18 lines
400 B
'use strict';
|
|
const {
|
|
ERR_HTTP_INVALID_HEADER_VALUE,
|
|
ERR_INVALID_CHAR
|
|
} = require('./errors.js');
|
|
|
|
const isInvalidHeaderValue = /[^\t\u0020-\u007E\u0080-\u00FF]/;
|
|
|
|
module.exports = (name, value) => {
|
|
if (typeof value === 'undefined') {
|
|
throw new ERR_HTTP_INVALID_HEADER_VALUE(value, name);
|
|
}
|
|
|
|
if (isInvalidHeaderValue.test(value)) {
|
|
throw new ERR_INVALID_CHAR('header content', name);
|
|
}
|
|
};
|