blob: 82cbc34509a419c8626b36aafd7807f564a94e57 (
plain)
1
2
3
4
5
6
7
8
9
10
11
|
'use strict';
const {ERR_INVALID_HTTP_TOKEN} = require('./errors.js');
const isRequestPseudoHeader = require('./is-request-pseudo-header.js');
const isValidHttpToken = /^[\^`\-\w!#$%&*+.|~]+$/;
module.exports = name => {
if (typeof name !== 'string' || (!isValidHttpToken.test(name) && !isRequestPseudoHeader(name))) {
throw new ERR_INVALID_HTTP_TOKEN('Header name', name);
}
};
|