3
3
const { gzip } = require ( 'zlib' )
4
4
5
5
const getIndexContent = require ( './content' )
6
-
7
- const appVersionCookieName = 'appVersion'
6
+ const getOptions = require ( './options' )
8
7
9
8
const getResponse = ( req , options , callback ) => {
10
9
try {
11
- const optionsFromReq = getOptionsFromReq ( req , options )
12
- const extendedOptions = getExtendedOptions ( optionsFromReq )
10
+ const extendedOptions = getOptions ( req , options )
13
11
14
12
if ( req . url === '/favicon.ico' ) {
15
13
const favicon = createFaviconResponse ( extendedOptions )
@@ -22,31 +20,6 @@ const getResponse = (req, options, callback) => {
22
20
}
23
21
}
24
22
25
- const getOptionsFromReq = ( req , options ) => {
26
- const version = getVersionFromReq ( req ) || options . version
27
- return Object . assign ( options , {
28
- version
29
- } )
30
- }
31
-
32
- const getVersionFromReq = req => {
33
- const cookieHeader = req . headers . cookie
34
- if ( ! cookieHeader ) return null
35
- const cookies = cookieHeader . split ( ';' )
36
- if ( ! cookies ) return null
37
- const cookie = cookies
38
- . map ( c => c . split ( '=' ) )
39
- . find ( ( [ n ] ) => n === appVersionCookieName )
40
- return cookie && cookie [ 1 ]
41
- }
42
-
43
- const getExtendedOptions = options => {
44
- const { origin, version } = options
45
- return Object . assign ( options , {
46
- root : [ origin , version ] . filter ( x => x ) . join ( '/' )
47
- } )
48
- }
49
-
50
23
const getIndexResponse = ( options , callback ) => {
51
24
getIndexContent ( options , ( err , content ) => {
52
25
if ( err ) return callback ( err )
0 commit comments