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.
12 lines
385 B
12 lines
385 B
'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);
|
|
}
|
|
};
|