-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
36 lines (34 loc) · 925 Bytes
/
test.js
File metadata and controls
36 lines (34 loc) · 925 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const test = require('tape')
const { getObjFromRawHeaders } = require('./index')
test('simple', function (t) {
const rawHeaders = [
'Server', 'Github.com',
'Server', 'Gitlab.com',
'A', 'c',
'A', 'd',
'date', 'Tue',
'date', 'Fri',
'cookie', 'a=b; b=c',
'Set-Cookie', 'a=b',
'Set-Cookie', 'b=c',
'referer', 'https://github.com',
'referer', 'https://gitlab.com',
'Connection', 'close',
'Content-Length', '2'
]
const rawHeadersObj = {
Server: 'Github.com',
A: 'c, d',
date: 'Tue, Fri',
cookie: 'a=b; b=c',
'Set-Cookie': ['a=b', 'b=c'],
referer: 'https://github.com',
Connection: 'close',
'Content-Length': '2'
}
const transformObj = getObjFromRawHeaders(rawHeaders)
t.deepEqual(
transformObj, rawHeadersObj
)
t.end()
})