File tree Expand file tree Collapse file tree 2 files changed +4
-114
lines changed Expand file tree Collapse file tree 2 files changed +4
-114
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 5
5
* Headers class offers convenient helpers
6
6
*/
7
7
8
- import { checkInvalidHeaderChar , checkIsHttpToken } from './common.js' ;
8
+ const invalidTokenRegex = / [ ^ \^ _ ` a - z A - Z \- 0 - 9 ! # $ % & ' * + . | ~ ] / ;
9
+ const invalidHeaderCharRegex = / [ ^ \t \x20 - \x7e \x80 - \xff ] / ;
9
10
10
11
function sanitizeName ( name ) {
11
12
name += '' ;
12
- if ( ! checkIsHttpToken ( name ) ) {
13
+ if ( invalidTokenRegex . test ( name ) ) {
13
14
throw new TypeError ( `${ name } is not a legal HTTP header name` ) ;
14
15
}
15
16
return name . toLowerCase ( ) ;
16
17
}
17
18
18
19
function sanitizeValue ( value ) {
19
20
value += '' ;
20
- if ( checkInvalidHeaderChar ( value ) ) {
21
+ if ( invalidHeaderCharRegex . test ( value ) ) {
21
22
throw new TypeError ( `${ value } is not a legal HTTP header value` ) ;
22
23
}
23
24
return value ;
You can’t perform that action at this time.
0 commit comments