@quintype/framework 7.28.4-fix-fastly.0 → 7.28.4-fix-fastly.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/framework",
3
- "version": "7.28.4-fix-fastly.0",
3
+ "version": "7.28.4-fix-fastly.1",
4
4
  "description": "Libraries to help build Quintype Node.js apps",
5
5
  "main": "index.js",
6
6
  "engines": {
@@ -18,7 +18,6 @@ exports.addCacheHeadersToResult = function addCacheHeadersToResult({
18
18
  if (cacheKeys === "DO_NOT_CACHE") {
19
19
  res.setHeader("Cache-Control", "private,no-cache,no-store,max-age=0");
20
20
  res.setHeader("Vary", "Accept-Encoding");
21
- cdnProviderVal === "fastly" && res.setHeader('Surrogate-Control', 'private,no-cache,no-store,max-age=0');
22
21
  res.setHeader(
23
22
  "Content-Security-Policy",
24
23
  `default-src data: 'unsafe-inline' 'unsafe-eval' https: http:;` +
@@ -47,19 +46,17 @@ exports.addCacheHeadersToResult = function addCacheHeadersToResult({
47
46
  );
48
47
  }
49
48
 
50
-
51
49
  res.setHeader("Vary", "Accept-Encoding");
52
50
 
53
51
  // Cloudflare Headers
54
- res.setHeader("Cache-Tag", _(cacheKeys).uniq().join(","));
52
+ cdnProviderVal === "cloudflare" && res.setHeader("Cache-Tag", _(cacheKeys).uniq().join(","));
55
53
 
56
54
  // Akamai Headers
57
55
  cdnProviderVal === "akamai" && res.setHeader("Edge-Cache-Tag", _(cacheKeys).uniq().join(","));
58
56
 
59
- // Fastly Headers
60
- cdnProviderVal === "fastly" && res.setHeader("Surrogate-Control", `public,max-age=${maxAge},s-maxage=${sMaxAge},stale-while-revalidate=1000,stale-if-error=${STALE_IF_ERROR_CACHE_DURATION}`);
57
+ // Fastly Headers
58
+ cdnProviderVal === "fastly" && res.setHeader("Surrogate-Key", _(cacheKeys).uniq().join(" "));
61
59
 
62
- res.setHeader("Surrogate-Key", _(cacheKeys).uniq().join(" "));
63
60
  res.setHeader(
64
61
  "Content-Security-Policy",
65
62
  `default-src data: 'unsafe-inline' 'unsafe-eval' https: http:;` +
@@ -78,7 +75,6 @@ exports.addCacheHeadersToResult = function addCacheHeadersToResult({
78
75
  } else {
79
76
  res.setHeader("Cache-Control", "public,max-age=15,s-maxage=60,stale-while-revalidate=150,stale-if-error=3600");
80
77
  res.setHeader("Vary", "Accept-Encoding");
81
- cdnProviderVal === "fastly" && res.setHeader("Surrogate-Control", "public,max-age=15,s-maxage=60,stale-while-revalidate=150,stale-if-error=3600");
82
78
  res.setHeader(
83
79
  "Content-Security-Policy",
84
80
  `default-src data: 'unsafe-inline' 'unsafe-eval' https: http:;` +
@@ -131,7 +131,6 @@ describe("Custom Route Handler", function () {
131
131
  "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400"
132
132
  )
133
133
  .expect("Vary", /Accept\-Encoding/)
134
- .expect("Surrogate-Key", "sp/42/101")
135
134
  .expect("Cache-Tag", "sp/42/101")
136
135
  .expect(301, done);
137
136
  });
@@ -149,7 +148,6 @@ describe("Custom Route Handler", function () {
149
148
  "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400"
150
149
  )
151
150
  .expect("Vary", /Accept\-Encoding/)
152
- .expect("Surrogate-Key", "sp/42/102")
153
151
  .expect("Cache-Tag", "sp/42/102")
154
152
  .expect(302, done);
155
153
  });
@@ -168,7 +166,6 @@ describe("Custom Route Handler", function () {
168
166
  "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400"
169
167
  )
170
168
  .expect("Vary", "Accept-Encoding")
171
- .expect("Surrogate-Key", "sp/42/103")
172
169
  .expect("Cache-Tag", "sp/42/103")
173
170
  .expect(200)
174
171
  .then((res) => {
@@ -193,7 +190,6 @@ describe("Custom Route Handler", function () {
193
190
  "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400"
194
191
  )
195
192
  .expect("Vary", "Accept-Encoding")
196
- .expect("Surrogate-Key", "sp/42/104")
197
193
  .expect("Cache-Tag", "sp/42/104")
198
194
  .expect(200)
199
195
  .then((res) => {
@@ -263,7 +259,6 @@ describe("Custom Route Handler", function () {
263
259
  "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400"
264
260
  )
265
261
  .expect("Vary", /Accept\-Encoding/)
266
- .expect("Surrogate-Key", "sp/42/105")
267
262
  .expect("Cache-Tag", "sp/42/105")
268
263
  .expect(301, done);
269
264
  });
@@ -280,7 +275,6 @@ describe("Custom Route Handler", function () {
280
275
  "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400"
281
276
  )
282
277
  .expect("Vary", /Accept\-Encoding/)
283
- .expect("Surrogate-Key", "sp/42/105")
284
278
  .expect("Cache-Tag", "sp/42/105")
285
279
  .expect("Content-Type", "text/plain; charset=utf-8")
286
280
  .expect(200, done);
@@ -298,7 +292,6 @@ describe("Custom Route Handler", function () {
298
292
  "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400"
299
293
  )
300
294
  .expect("Vary", "Accept-Encoding")
301
- .expect("Surrogate-Key", "sp/42/104")
302
295
  .expect("Cache-Tag", "sp/42/104")
303
296
  .expect("Content-Type", "text/html; charset=utf-8")
304
297
  .expect(200, done);
@@ -212,7 +212,6 @@ describe("Isomorphic Handler", function () {
212
212
  .expect("Content-Type", /html/)
213
213
  .expect("Cache-Control", "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400")
214
214
  .expect("Vary", "Accept-Encoding")
215
- .expect("Surrogate-Key", "foo bar")
216
215
  .expect("Cache-Tag", "foo,bar")
217
216
  .expect(200, done);
218
217
  });
@@ -1,487 +1,487 @@
1
- const express = require("express");
2
- const React = require("react");
3
- const assert = require("assert");
4
- const { isomorphicRoutes } = require("../../server/routes");
5
- const supertest = require("supertest");
1
+ const express = require('express')
2
+ const React = require('react')
3
+ const assert = require('assert')
4
+ const { isomorphicRoutes } = require('../../server/routes')
5
+ const supertest = require('supertest')
6
6
 
7
7
  const redirectUrls = {
8
- "/tag/:slug": { destinationUrl: "/topic/:slug", statusCode: 301 },
9
- "/india/:someslug": { destinationUrl: "/news/:someslug", statusCode: 301 },
10
- "/india/news/:someslug": {
11
- destinationUrl: "/india/:someslug",
12
- statusCode: 301,
8
+ '/tag/:slug': { destinationUrl: '/topic/:slug', statusCode: 301 },
9
+ '/india/:someslug': { destinationUrl: '/news/:someslug', statusCode: 301 },
10
+ '/india/news/:someslug': {
11
+ destinationUrl: '/india/:someslug',
12
+ statusCode: 301
13
13
  },
14
- "/india/foo/:param/:param1": {
15
- destinationUrl: "/india/:param",
16
- statusCode: 302,
14
+ '/india/foo/:param/:param1': {
15
+ destinationUrl: '/india/:param',
16
+ statusCode: 302
17
17
  },
18
- "/:param1/something/:param2": {
19
- destinationUrl: "/:param2/something/:param1",
20
- statusCode: 301,
18
+ '/:param1/something/:param2': {
19
+ destinationUrl: '/:param2/something/:param1',
20
+ statusCode: 301
21
21
  },
22
- "/something/new": {
23
- destinationUrl: "https://www.google.com/something",
24
- statusCode: 301,
22
+ '/something/new': {
23
+ destinationUrl: 'https://www.google.com/something',
24
+ statusCode: 301
25
25
  },
26
- "/something/:param1": {
27
- destinationUrl: "https://www.google.com/:param1",
28
- statusCode: 301,
26
+ '/something/:param1': {
27
+ destinationUrl: 'https://www.google.com/:param1',
28
+ statusCode: 301
29
29
  },
30
- "/moved-permanently-1": {
31
- destinationUrl: "/permanent-location-1",
32
- statusCode: 301,
30
+ '/moved-permanently-1': {
31
+ destinationUrl: '/permanent-location-1',
32
+ statusCode: 301
33
33
  },
34
- "/moved-permanently-2\t": {
35
- destinationUrl: "/permanent-location-2",
36
- statusCode: 301,
34
+ '/moved-permanently-2\t': {
35
+ destinationUrl: '/permanent-location-2',
36
+ statusCode: 301
37
37
  },
38
- "/moved-permanently-3\t": {
39
- destinationUrl: "/permanent-location-3",
40
- statusCode: 301,
38
+ '/moved-permanently-3\t': {
39
+ destinationUrl: '/permanent-location-3',
40
+ statusCode: 301
41
41
  },
42
- "/moved-permanently-4\t": {
43
- destinationUrl: "/permanent-location-4",
44
- statusCode: 301,
42
+ '/moved-permanently-4\t': {
43
+ destinationUrl: '/permanent-location-4',
44
+ statusCode: 301
45
45
  },
46
- "/moved-permanently-5\t": {
47
- destinationUrl: "/permanent-location-5",
48
- statusCode: 301,
46
+ '/moved-permanently-5\t': {
47
+ destinationUrl: '/permanent-location-5',
48
+ statusCode: 301
49
49
  },
50
- "/moved-permanently-6\t": {
51
- destinationUrl: "/permanent-location-6",
52
- statusCode: 301,
50
+ '/moved-permanently-6\t': {
51
+ destinationUrl: '/permanent-location-6',
52
+ statusCode: 301
53
53
  },
54
- "/moved-permanently-7\t": {
55
- destinationUrl: "/permanent-location-7",
56
- statusCode: 301,
54
+ '/moved-permanently-7\t': {
55
+ destinationUrl: '/permanent-location-7',
56
+ statusCode: 301
57
57
  },
58
- "/moved-permanently-8\t": {
59
- destinationUrl: "/permanent-location-8",
60
- statusCode: 301,
58
+ '/moved-permanently-8\t': {
59
+ destinationUrl: '/permanent-location-8',
60
+ statusCode: 301
61
61
  },
62
- "/moved-permanently-9\t": {
63
- destinationUrl: "/permanent-location-9",
64
- statusCode: 301,
62
+ '/moved-permanently-9\t': {
63
+ destinationUrl: '/permanent-location-9',
64
+ statusCode: 301
65
65
  },
66
- "/moved-permanently-10": {
67
- destinationUrl: "/permanent-location-10",
68
- statusCode: 301,
66
+ '/moved-permanently-10': {
67
+ destinationUrl: '/permanent-location-10',
68
+ statusCode: 301
69
69
  },
70
- "/moved-permanently-11": {
71
- destinationUrl: "/permanent-location-11",
72
- statusCode: 301,
70
+ '/moved-permanently-11': {
71
+ destinationUrl: '/permanent-location-11',
72
+ statusCode: 301
73
73
  },
74
- "/moved-permanently-12": {
75
- destinationUrl: "/permanent-location-12",
76
- statusCode: 301,
74
+ '/moved-permanently-12': {
75
+ destinationUrl: '/permanent-location-12',
76
+ statusCode: 301
77
77
  },
78
- "/moved-permanently-13": {
79
- destinationUrl: "/permanent-location-13",
80
- statusCode: 301,
78
+ '/moved-permanently-13': {
79
+ destinationUrl: '/permanent-location-13',
80
+ statusCode: 301
81
81
  },
82
- "/moved-permanently-14": {
83
- destinationUrl: "/permanent-location-14",
84
- statusCode: 301,
82
+ '/moved-permanently-14': {
83
+ destinationUrl: '/permanent-location-14',
84
+ statusCode: 301
85
85
  },
86
- "/moved-permanently-15": {
87
- destinationUrl: "/permanent-location-15",
88
- statusCode: 301,
86
+ '/moved-permanently-15': {
87
+ destinationUrl: '/permanent-location-15',
88
+ statusCode: 301
89
89
  },
90
- "/moved-permanently-16": {
91
- destinationUrl: "/permanent-location-16",
92
- statusCode: 301,
90
+ '/moved-permanently-16': {
91
+ destinationUrl: '/permanent-location-16',
92
+ statusCode: 301
93
93
  },
94
- "/moved-permanently-17": {
95
- destinationUrl: "/permanent-location-17",
96
- statusCode: 301,
94
+ '/moved-permanently-17': {
95
+ destinationUrl: '/permanent-location-17',
96
+ statusCode: 301
97
97
  },
98
- "/moved-permanently-18": {
99
- destinationUrl: "/permanent-location-18",
100
- statusCode: 301,
98
+ '/moved-permanently-18': {
99
+ destinationUrl: '/permanent-location-18',
100
+ statusCode: 301
101
101
  },
102
- "/moved-permanently-19": {
103
- destinationUrl: "/permanent-location-19",
104
- statusCode: 301,
102
+ '/moved-permanently-19': {
103
+ destinationUrl: '/permanent-location-19',
104
+ statusCode: 301
105
105
  },
106
- "/moved-permanently-20": {
107
- destinationUrl: "/permanent-location-20",
108
- statusCode: 301,
106
+ '/moved-permanently-20': {
107
+ destinationUrl: '/permanent-location-20',
108
+ statusCode: 301
109
109
  },
110
- "/moved-permanently-21": {
111
- destinationUrl: "/permanent-location-21",
112
- statusCode: 301,
110
+ '/moved-permanently-21': {
111
+ destinationUrl: '/permanent-location-21',
112
+ statusCode: 301
113
113
  },
114
- "/moved-permanently-22": {
115
- destinationUrl: "/permanent-location-22",
116
- statusCode: 301,
114
+ '/moved-permanently-22': {
115
+ destinationUrl: '/permanent-location-22',
116
+ statusCode: 301
117
117
  },
118
- "/moved-permanently-23": {
119
- destinationUrl: "/permanent-location-23",
120
- statusCode: 301,
118
+ '/moved-permanently-23': {
119
+ destinationUrl: '/permanent-location-23',
120
+ statusCode: 301
121
121
  },
122
- "/moved-permanently-24": {
123
- destinationUrl: "/permanent-location-24",
124
- statusCode: 301,
122
+ '/moved-permanently-24': {
123
+ destinationUrl: '/permanent-location-24',
124
+ statusCode: 301
125
125
  },
126
- "/moved-permanently-25": {
127
- destinationUrl: "/permanent-location-25",
128
- statusCode: 301,
126
+ '/moved-permanently-25': {
127
+ destinationUrl: '/permanent-location-25',
128
+ statusCode: 301
129
129
  },
130
- "/moved-permanently-26": {
131
- destinationUrl: "/permanent-location-26",
132
- statusCode: 301,
130
+ '/moved-permanently-26': {
131
+ destinationUrl: '/permanent-location-26',
132
+ statusCode: 301
133
133
  },
134
- "/moved-permanently-27": {
135
- destinationUrl: "/permanent-location-27",
136
- statusCode: 301,
134
+ '/moved-permanently-27': {
135
+ destinationUrl: '/permanent-location-27',
136
+ statusCode: 301
137
137
  },
138
- "/moved-permanently-28": {
139
- destinationUrl: "/permanent-location-28",
140
- statusCode: 301,
138
+ '/moved-permanently-28': {
139
+ destinationUrl: '/permanent-location-28',
140
+ statusCode: 301
141
141
  },
142
- "/moved-permanently-29": {
143
- destinationUrl: "/permanent-location-29",
144
- statusCode: 301,
142
+ '/moved-permanently-29': {
143
+ destinationUrl: '/permanent-location-29',
144
+ statusCode: 301
145
145
  },
146
- "/moved-permanently-30": {
147
- destinationUrl: "/permanent-location-30",
148
- statusCode: 301,
146
+ '/moved-permanently-30': {
147
+ destinationUrl: '/permanent-location-30',
148
+ statusCode: 301
149
149
  },
150
- "/moved-permanently-31": {
151
- destinationUrl: "/permanent-location-31",
152
- statusCode: 301,
150
+ '/moved-permanently-31': {
151
+ destinationUrl: '/permanent-location-31',
152
+ statusCode: 301
153
153
  },
154
- "/moved-permanently-32": {
155
- destinationUrl: "/permanent-location-32",
156
- statusCode: 301,
154
+ '/moved-permanently-32': {
155
+ destinationUrl: '/permanent-location-32',
156
+ statusCode: 301
157
157
  },
158
- "/moved-permanently-33": {
159
- destinationUrl: "/permanent-location-33",
160
- statusCode: 301,
158
+ '/moved-permanently-33': {
159
+ destinationUrl: '/permanent-location-33',
160
+ statusCode: 301
161
161
  },
162
- "/moved-permanently-34": {
163
- destinationUrl: "/permanent-location-34",
164
- statusCode: 301,
162
+ '/moved-permanently-34': {
163
+ destinationUrl: '/permanent-location-34',
164
+ statusCode: 301
165
165
  },
166
- "/moved-permanently-35": {
167
- destinationUrl: "/permanent-location-35",
168
- statusCode: 301,
166
+ '/moved-permanently-35': {
167
+ destinationUrl: '/permanent-location-35',
168
+ statusCode: 301
169
169
  },
170
- "/moved-permanently-36": {
171
- destinationUrl: "/permanent-location-36",
172
- statusCode: 301,
170
+ '/moved-permanently-36': {
171
+ destinationUrl: '/permanent-location-36',
172
+ statusCode: 301
173
173
  },
174
- "/moved-permanently-37": {
175
- destinationUrl: "/permanent-location-37",
176
- statusCode: 301,
174
+ '/moved-permanently-37': {
175
+ destinationUrl: '/permanent-location-37',
176
+ statusCode: 301
177
177
  },
178
- "/moved-permanently-38": {
179
- destinationUrl: "/permanent-location-38",
180
- statusCode: 301,
178
+ '/moved-permanently-38': {
179
+ destinationUrl: '/permanent-location-38',
180
+ statusCode: 301
181
181
  },
182
- "/moved-permanently-39": {
183
- destinationUrl: "/permanent-location-39",
184
- statusCode: 301,
182
+ '/moved-permanently-39': {
183
+ destinationUrl: '/permanent-location-39',
184
+ statusCode: 301
185
185
  },
186
- "/moved-permanently-40": {
187
- destinationUrl: "/permanent-location-40",
188
- statusCode: 301,
186
+ '/moved-permanently-40': {
187
+ destinationUrl: '/permanent-location-40',
188
+ statusCode: 301
189
189
  },
190
- "/moved-permanently-41": {
191
- destinationUrl: "/permanent-location-41",
192
- statusCode: 301,
190
+ '/moved-permanently-41': {
191
+ destinationUrl: '/permanent-location-41',
192
+ statusCode: 301
193
193
  },
194
- "/moved-permanently-42": {
195
- destinationUrl: "/permanent-location-42",
196
- statusCode: 301,
194
+ '/moved-permanently-42': {
195
+ destinationUrl: '/permanent-location-42',
196
+ statusCode: 301
197
197
  },
198
- "/moved-permanently-43": {
199
- destinationUrl: "/permanent-location-43",
200
- statusCode: 301,
198
+ '/moved-permanently-43': {
199
+ destinationUrl: '/permanent-location-43',
200
+ statusCode: 301
201
201
  },
202
- "/moved-permanently-44": {
203
- destinationUrl: "/permanent-location-44",
204
- statusCode: 301,
202
+ '/moved-permanently-44': {
203
+ destinationUrl: '/permanent-location-44',
204
+ statusCode: 301
205
205
  },
206
- "/moved-permanently-45": {
207
- destinationUrl: "/permanent-location-45",
208
- statusCode: 301,
206
+ '/moved-permanently-45': {
207
+ destinationUrl: '/permanent-location-45',
208
+ statusCode: 301
209
209
  },
210
- "/moved-permanently-46": {
211
- destinationUrl: "/permanent-location-46",
212
- statusCode: 301,
210
+ '/moved-permanently-46': {
211
+ destinationUrl: '/permanent-location-46',
212
+ statusCode: 301
213
213
  },
214
- "/moved-permanently-47": {
215
- destinationUrl: "/permanent-location-47",
216
- statusCode: 301,
214
+ '/moved-permanently-47': {
215
+ destinationUrl: '/permanent-location-47',
216
+ statusCode: 301
217
217
  },
218
- "/moved-permanently-48": {
219
- destinationUrl: "/permanent-location-48",
220
- statusCode: 301,
218
+ '/moved-permanently-48': {
219
+ destinationUrl: '/permanent-location-48',
220
+ statusCode: 301
221
221
  },
222
- "/moved-permanently-49": {
223
- destinationUrl: "/permanent-location-49",
224
- statusCode: 301,
222
+ '/moved-permanently-49': {
223
+ destinationUrl: '/permanent-location-49',
224
+ statusCode: 301
225
225
  },
226
- "/moved-permanently-50": {
227
- destinationUrl: "/permanent-location-50",
228
- statusCode: 301,
226
+ '/moved-permanently-50': {
227
+ destinationUrl: '/permanent-location-50',
228
+ statusCode: 301
229
229
  },
230
- "/moved-permanently-51": {
231
- destinationUrl: "/permanent-location-51",
232
- statusCode: 301,
230
+ '/moved-permanently-51': {
231
+ destinationUrl: '/permanent-location-51',
232
+ statusCode: 301
233
233
  },
234
- "/moved-permanently-52": {
235
- destinationUrl: "/permanent-location-52",
236
- statusCode: 301,
234
+ '/moved-permanently-52': {
235
+ destinationUrl: '/permanent-location-52',
236
+ statusCode: 301
237
237
  },
238
- "/moved-permanently-53": {
239
- destinationUrl: "/permanent-location-53",
240
- statusCode: 301,
238
+ '/moved-permanently-53': {
239
+ destinationUrl: '/permanent-location-53',
240
+ statusCode: 301
241
241
  },
242
- "/moved-permanently-54": {
243
- destinationUrl: "/permanent-location-54",
244
- statusCode: 301,
242
+ '/moved-permanently-54': {
243
+ destinationUrl: '/permanent-location-54',
244
+ statusCode: 301
245
245
  },
246
- "/moved-permanently-55": {
247
- destinationUrl: "/permanent-location-55",
248
- statusCode: 301,
246
+ '/moved-permanently-55': {
247
+ destinationUrl: '/permanent-location-55',
248
+ statusCode: 301
249
249
  },
250
- "/moved-permanently-56": {
251
- destinationUrl: "/permanent-location-56",
252
- statusCode: 301,
250
+ '/moved-permanently-56': {
251
+ destinationUrl: '/permanent-location-56',
252
+ statusCode: 301
253
253
  },
254
- "/moved-permanently-57": {
255
- destinationUrl: "/permanent-location-57",
256
- statusCode: 301,
254
+ '/moved-permanently-57': {
255
+ destinationUrl: '/permanent-location-57',
256
+ statusCode: 301
257
257
  },
258
- "/moved-permanently-58": {
259
- destinationUrl: "/permanent-location-58",
260
- statusCode: 301,
258
+ '/moved-permanently-58': {
259
+ destinationUrl: '/permanent-location-58',
260
+ statusCode: 301
261
261
  },
262
- "/moved-permanently-59": {
263
- destinationUrl: "/permanent-location-59",
264
- statusCode: 301,
262
+ '/moved-permanently-59': {
263
+ destinationUrl: '/permanent-location-59',
264
+ statusCode: 301
265
265
  },
266
- "/moved-permanently-60": {
267
- destinationUrl: "/permanent-location-60",
268
- statusCode: 301,
266
+ '/moved-permanently-60': {
267
+ destinationUrl: '/permanent-location-60',
268
+ statusCode: 301
269
269
  },
270
- "/moved-permanently-61": {
271
- destinationUrl: "/permanent-location-61",
272
- statusCode: 301,
270
+ '/moved-permanently-61': {
271
+ destinationUrl: '/permanent-location-61',
272
+ statusCode: 301
273
273
  },
274
- "/moved-permanently-62": {
275
- destinationUrl: "/permanent-location-62",
276
- statusCode: 301,
274
+ '/moved-permanently-62': {
275
+ destinationUrl: '/permanent-location-62',
276
+ statusCode: 301
277
277
  },
278
- "/moved-permanently-63": {
279
- destinationUrl: "/permanent-location-63",
280
- statusCode: 301,
278
+ '/moved-permanently-63': {
279
+ destinationUrl: '/permanent-location-63',
280
+ statusCode: 301
281
281
  },
282
- "/moved-permanently-64": {
283
- destinationUrl: "/permanent-location-64",
284
- statusCode: 301,
282
+ '/moved-permanently-64': {
283
+ destinationUrl: '/permanent-location-64',
284
+ statusCode: 301
285
285
  },
286
- "/moved-permanently-65": {
287
- destinationUrl: "/permanent-location-65",
288
- statusCode: 301,
286
+ '/moved-permanently-65': {
287
+ destinationUrl: '/permanent-location-65',
288
+ statusCode: 301
289
289
  },
290
- "/moved-permanently-66": {
291
- destinationUrl: "/permanent-location-66",
292
- statusCode: 301,
290
+ '/moved-permanently-66': {
291
+ destinationUrl: '/permanent-location-66',
292
+ statusCode: 301
293
293
  },
294
- "/moved-permanently-67": {
295
- destinationUrl: "/permanent-location-67",
296
- statusCode: 301,
294
+ '/moved-permanently-67': {
295
+ destinationUrl: '/permanent-location-67',
296
+ statusCode: 301
297
297
  },
298
- "/moved-permanently-68": {
299
- destinationUrl: "/permanent-location-68",
300
- statusCode: 301,
298
+ '/moved-permanently-68': {
299
+ destinationUrl: '/permanent-location-68',
300
+ statusCode: 301
301
301
  },
302
- "/moved-permanently-69": {
303
- destinationUrl: "/permanent-location-69",
304
- statusCode: 301,
302
+ '/moved-permanently-69': {
303
+ destinationUrl: '/permanent-location-69',
304
+ statusCode: 301
305
305
  },
306
- "/moved-permanently-70": {
307
- destinationUrl: "/permanent-location-70",
308
- statusCode: 301,
306
+ '/moved-permanently-70': {
307
+ destinationUrl: '/permanent-location-70',
308
+ statusCode: 301
309
309
  },
310
- "/moved-permanently-71": {
311
- destinationUrl: "/permanent-location-71",
312
- statusCode: 301,
310
+ '/moved-permanently-71': {
311
+ destinationUrl: '/permanent-location-71',
312
+ statusCode: 301
313
313
  },
314
- "/moved-permanently-72": {
315
- destinationUrl: "/permanent-location-72",
316
- statusCode: 301,
314
+ '/moved-permanently-72': {
315
+ destinationUrl: '/permanent-location-72',
316
+ statusCode: 301
317
317
  },
318
- "/moved-permanently-73": {
319
- destinationUrl: "/permanent-location-73",
320
- statusCode: 301,
318
+ '/moved-permanently-73': {
319
+ destinationUrl: '/permanent-location-73',
320
+ statusCode: 301
321
321
  },
322
- "/moved-permanently-74": {
323
- destinationUrl: "/permanent-location-74",
324
- statusCode: 301,
322
+ '/moved-permanently-74': {
323
+ destinationUrl: '/permanent-location-74',
324
+ statusCode: 301
325
325
  },
326
- "/moved-permanently-75": {
327
- destinationUrl: "/permanent-location-75",
328
- statusCode: 301,
326
+ '/moved-permanently-75': {
327
+ destinationUrl: '/permanent-location-75',
328
+ statusCode: 301
329
329
  },
330
- "/moved-permanently-76": {
331
- destinationUrl: "/permanent-location-76",
332
- statusCode: 301,
330
+ '/moved-permanently-76': {
331
+ destinationUrl: '/permanent-location-76',
332
+ statusCode: 301
333
333
  },
334
- "/moved-permanently-77": {
335
- destinationUrl: "/permanent-location-77",
336
- statusCode: 301,
334
+ '/moved-permanently-77': {
335
+ destinationUrl: '/permanent-location-77',
336
+ statusCode: 301
337
337
  },
338
- "/moved-permanently-78": {
339
- destinationUrl: "/permanent-location-78",
340
- statusCode: 301,
338
+ '/moved-permanently-78': {
339
+ destinationUrl: '/permanent-location-78',
340
+ statusCode: 301
341
341
  },
342
- "/moved-permanently-79": {
343
- destinationUrl: "/permanent-location-79",
344
- statusCode: 301,
342
+ '/moved-permanently-79': {
343
+ destinationUrl: '/permanent-location-79',
344
+ statusCode: 301
345
345
  },
346
- "/moved-permanently-80": {
347
- destinationUrl: "/permanent-location-80",
348
- statusCode: 301,
346
+ '/moved-permanently-80': {
347
+ destinationUrl: '/permanent-location-80',
348
+ statusCode: 301
349
349
  },
350
- "/moved-permanently-81": {
351
- destinationUrl: "/permanent-location-81",
352
- statusCode: 301,
350
+ '/moved-permanently-81': {
351
+ destinationUrl: '/permanent-location-81',
352
+ statusCode: 301
353
353
  },
354
- "/moved-permanently-82": {
355
- destinationUrl: "/permanent-location-82",
356
- statusCode: 301,
354
+ '/moved-permanently-82': {
355
+ destinationUrl: '/permanent-location-82',
356
+ statusCode: 301
357
357
  },
358
- "/moved-permanently-83": {
359
- destinationUrl: "/permanent-location-83",
360
- statusCode: 301,
358
+ '/moved-permanently-83': {
359
+ destinationUrl: '/permanent-location-83',
360
+ statusCode: 301
361
361
  },
362
- "/moved-permanently-84": {
363
- destinationUrl: "/permanent-location-84",
364
- statusCode: 301,
362
+ '/moved-permanently-84': {
363
+ destinationUrl: '/permanent-location-84',
364
+ statusCode: 301
365
365
  },
366
- "/moved-permanently-85": {
367
- destinationUrl: "/permanent-location-85",
368
- statusCode: 301,
366
+ '/moved-permanently-85': {
367
+ destinationUrl: '/permanent-location-85',
368
+ statusCode: 301
369
369
  },
370
- "/moved-permanently-86": {
371
- destinationUrl: "/permanent-location-86",
372
- statusCode: 301,
370
+ '/moved-permanently-86': {
371
+ destinationUrl: '/permanent-location-86',
372
+ statusCode: 301
373
373
  },
374
- "/moved-permanently-87": {
375
- destinationUrl: "/permanent-location-87",
376
- statusCode: 301,
374
+ '/moved-permanently-87': {
375
+ destinationUrl: '/permanent-location-87',
376
+ statusCode: 301
377
377
  },
378
- "/moved-permanently-88": {
379
- destinationUrl: "/permanent-location-88",
380
- statusCode: 301,
378
+ '/moved-permanently-88': {
379
+ destinationUrl: '/permanent-location-88',
380
+ statusCode: 301
381
381
  },
382
- "/moved-permanently-89": {
383
- destinationUrl: "/permanent-location-89",
384
- statusCode: 301,
382
+ '/moved-permanently-89': {
383
+ destinationUrl: '/permanent-location-89',
384
+ statusCode: 301
385
385
  },
386
- "/moved-permanently-90": {
387
- destinationUrl: "/permanent-location-90",
388
- statusCode: 301,
386
+ '/moved-permanently-90': {
387
+ destinationUrl: '/permanent-location-90',
388
+ statusCode: 301
389
389
  },
390
- "/moved-permanently-91": {
391
- destinationUrl: "/permanent-location-91",
392
- statusCode: 301,
390
+ '/moved-permanently-91': {
391
+ destinationUrl: '/permanent-location-91',
392
+ statusCode: 301
393
393
  },
394
- "/moved-permanently-92": {
395
- destinationUrl: "/permanent-location-92",
396
- statusCode: 301,
394
+ '/moved-permanently-92': {
395
+ destinationUrl: '/permanent-location-92',
396
+ statusCode: 301
397
397
  },
398
- "/moved-permanently-93": {
399
- destinationUrl: "/permanent-location-93",
400
- statusCode: 301,
398
+ '/moved-permanently-93': {
399
+ destinationUrl: '/permanent-location-93',
400
+ statusCode: 301
401
401
  },
402
- "/moved-permanently-94": {
403
- destinationUrl: "/permanent-location-94",
404
- statusCode: 301,
402
+ '/moved-permanently-94': {
403
+ destinationUrl: '/permanent-location-94',
404
+ statusCode: 301
405
405
  },
406
- "/moved-permanently-95": {
407
- destinationUrl: "/permanent-location-95",
408
- statusCode: 301,
406
+ '/moved-permanently-95': {
407
+ destinationUrl: '/permanent-location-95',
408
+ statusCode: 301
409
409
  },
410
- "/moved-permanently-96": {
411
- destinationUrl: "/permanent-location-96",
412
- statusCode: 301,
410
+ '/moved-permanently-96': {
411
+ destinationUrl: '/permanent-location-96',
412
+ statusCode: 301
413
413
  },
414
- "/moved-permanently-97": {
415
- destinationUrl: "/permanent-location-97",
416
- statusCode: 301,
414
+ '/moved-permanently-97': {
415
+ destinationUrl: '/permanent-location-97',
416
+ statusCode: 301
417
417
  },
418
- "/moved-permanently-98": {
419
- destinationUrl: "/permanent-location-98",
420
- statusCode: 301,
418
+ '/moved-permanently-98': {
419
+ destinationUrl: '/permanent-location-98',
420
+ statusCode: 301
421
421
  },
422
- "/moved-permanently-99": {
423
- destinationUrl: "/permanent-location-99",
424
- statusCode: 301,
422
+ '/moved-permanently-99': {
423
+ destinationUrl: '/permanent-location-99',
424
+ statusCode: 301
425
425
  },
426
- "/moved-permanently-100": {
427
- destinationUrl: "/permanent-location-100",
428
- statusCode: 301,
429
- },
430
- };
426
+ '/moved-permanently-100': {
427
+ destinationUrl: '/permanent-location-100',
428
+ statusCode: 301
429
+ }
430
+ }
431
431
 
432
- function getRedirectUrl() {
433
- return redirectUrls;
432
+ function getRedirectUrl () {
433
+ return redirectUrls
434
434
  }
435
435
 
436
- function pickComponent(pageType) {
437
- return ({ data }) => <div data-page-type={pageType}>{data.text}</div>;
436
+ function pickComponent (pageType) {
437
+ return ({ data }) => <div data-page-type={pageType}>{data.text}</div>
438
438
  }
439
439
 
440
- function getClientStub(hostname) {
440
+ function getClientStub (hostname) {
441
441
  return {
442
- getHostname: () => "demo.quintype.io",
442
+ getHostname: () => 'demo.quintype.io',
443
443
  getConfig: () =>
444
444
  Promise.resolve({
445
- config: { foo: "bar", "theme-attributes": {} },
446
- "publisher-id": 42,
445
+ config: { foo: 'bar', 'theme-attributes': {} },
446
+ 'publisher-id': 42
447
447
  }),
448
- getCustomPathData: (path) => {
448
+ getCustomPathData: path => {
449
449
  switch (path) {
450
- case "/moved-permanently-1":
450
+ case '/moved-permanently-1':
451
451
  return Promise.resolve({
452
452
  page: {
453
453
  id: 101,
454
- type: "redirect",
455
- "status-code": 301,
456
- "destination-path": "/permanent-location-1",
457
- },
458
- });
459
- case "/moved-temporarily-1":
454
+ type: 'redirect',
455
+ 'status-code': 301,
456
+ 'destination-path': '/permanent-location-1'
457
+ }
458
+ })
459
+ case '/moved-temporarily-1':
460
460
  return Promise.resolve({
461
461
  page: {
462
462
  id: 102,
463
- type: "redirect",
464
- "status-code": 302,
465
- "destination-path": "/temporarily-location-1",
466
- },
467
- });
463
+ type: 'redirect',
464
+ 'status-code': 302,
465
+ 'destination-path': '/temporarily-location-1'
466
+ }
467
+ })
468
468
 
469
469
  default:
470
- return Promise.resolve({ page: null, "status-code": 404 });
470
+ return Promise.resolve({ page: null, 'status-code': 404 })
471
471
  }
472
- },
473
- };
472
+ }
473
+ }
474
474
  }
475
475
 
476
- function createApp(loadData, routes, opts = {}) {
477
- const app = express();
476
+ function createApp (loadData, routes, opts = {}) {
477
+ const app = express()
478
478
  isomorphicRoutes(
479
479
  app,
480
480
  Object.assign(
481
481
  {
482
482
  assetHelper: {
483
- assetHash: (file) => (file === "app.js" ? "abcdef" : null),
484
- assetPath: (file) => `/assets/${file}`,
483
+ assetHash: file => (file === 'app.js' ? 'abcdef' : null),
484
+ assetPath: file => `/assets/${file}`
485
485
  },
486
486
  getClient: getClientStub,
487
487
  generateRoutes: () => routes,
@@ -490,177 +490,170 @@ function createApp(loadData, routes, opts = {}) {
490
490
  renderLayout: (res, { store, title, content }) =>
491
491
  res.send(JSON.stringify({ store: store.getState(), title, content })),
492
492
  handleNotFound: false,
493
- publisherConfig: {},
493
+ publisherConfig: {}
494
494
  },
495
495
  opts
496
496
  )
497
- );
497
+ )
498
498
 
499
- return app;
499
+ return app
500
500
  }
501
501
 
502
- describe("Redirect Routes Handler", function () {
503
- it("Redirects all the urls with status code to 301 if redirectUrls is present", function (done) {
502
+ describe('Redirect Routes Handler', function () {
503
+ it('Redirects all the urls with status code to 301 if redirectUrls is present', function (done) {
504
504
  const app = createApp(
505
505
  (pageType, params, config, client, { host, next }) => next(),
506
- [{ pageType: "story-page", path: "/*" }],
506
+ [{ pageType: 'story-page', path: '/*' }],
507
507
  {
508
- redirectUrls,
508
+ redirectUrls
509
509
  }
510
- );
510
+ )
511
511
  supertest(app)
512
- .get("/moved-permanently-1")
513
- .expect("Location", "/permanent-location-1")
514
- .expect(301, done);
515
- });
512
+ .get('/moved-permanently-1')
513
+ .expect('Location', '/permanent-location-1')
514
+ .expect(301, done)
515
+ })
516
516
 
517
- it("Redirects all the urls with status code to 302 if redirectUrls is present", function (done) {
517
+ it('Redirects all the urls with status code to 302 if redirectUrls is present', function (done) {
518
518
  const app = createApp(
519
519
  (pageType, params, config, client, { host, next }) => next(),
520
- [{ pageType: "story-page", path: "/*" }],
520
+ [{ pageType: 'story-page', path: '/*' }],
521
521
  {
522
522
  redirectUrls: [
523
523
  {
524
- sourceUrl: "/moved-temporarily-1",
525
- destinationUrl: "/temporarily-location-1",
526
- statusCode: 302,
527
- },
528
- ],
524
+ sourceUrl: '/moved-temporarily-1',
525
+ destinationUrl: '/temporarily-location-1',
526
+ statusCode: 302
527
+ }
528
+ ]
529
529
  }
530
- );
530
+ )
531
531
  supertest(app)
532
- .get("/moved-temporarily-1")
533
- .expect("Location", "/temporarily-location-1")
534
- .expect(302, done);
535
- });
532
+ .get('/moved-temporarily-1')
533
+ .expect('Location', '/temporarily-location-1')
534
+ .expect(302, done)
535
+ })
536
536
 
537
- it("Renders homepage when redirect urls are present", function (done) {
537
+ it('Renders homepage when redirect urls are present', function (done) {
538
538
  const app = createApp(
539
539
  (pageType, params, config, client, { host, next }) =>
540
- Promise.resolve({ pageType, data: { text: "foobar", host } }),
541
- [{ pageType: "home-page", path: "/" }],
540
+ Promise.resolve({ pageType, data: { text: 'foobar', host } }),
541
+ [{ pageType: 'home-page', path: '/' }],
542
542
  {
543
543
  redirectUrls: [
544
544
  {
545
- sourceUrl: "/moved-temporarily-1",
546
- destinationUrl: "/temporarily-location-1",
547
- statusCode: 302,
548
- },
549
- ],
545
+ sourceUrl: '/moved-temporarily-1',
546
+ destinationUrl: '/temporarily-location-1',
547
+ statusCode: 302
548
+ }
549
+ ]
550
550
  }
551
- );
551
+ )
552
552
  supertest(app)
553
- .get("/")
554
- .expect("Content-Type", /html/)
553
+ .get('/')
554
+ .expect('Content-Type', /html/)
555
555
  .expect(200)
556
- .then((res) => {
557
- const response = JSON.parse(res.text);
558
- assert.equal(
559
- '<div data-page-type="home-page">foobar</div>',
560
- response.content
561
- );
562
- assert.equal("foobar", response.store.qt.data.text);
563
- assert.equal("127.0.0.1", response.store.qt.data.host);
564
- assert.equal("home-page", response.store.qt.pageType);
556
+ .then(res => {
557
+ const response = JSON.parse(res.text)
558
+ assert.equal('<div data-page-type="home-page">foobar</div>', response.content)
559
+ assert.equal('foobar', response.store.qt.data.text)
560
+ assert.equal('127.0.0.1', response.store.qt.data.host)
561
+ assert.equal('home-page', response.store.qt.pageType)
565
562
  })
566
- .then(done);
567
- });
563
+ .then(done)
564
+ })
568
565
 
569
- it("Redirects all the urls with status code to 301 if redirectUrls function is present", function (done) {
566
+ it('Redirects all the urls with status code to 301 if redirectUrls function is present', function (done) {
570
567
  const app = createApp(
571
568
  (pageType, params, config, client, { host, next }) => next(),
572
- [{ pageType: "story-page", path: "/*" }],
569
+ [{ pageType: 'story-page', path: '/*' }],
573
570
  { redirectUrls: getRedirectUrl }
574
- );
571
+ )
575
572
  supertest(app)
576
- .get("/moved-permanently-1")
577
- .expect("Location", "/permanent-location-1")
578
- .expect(301, done);
579
- });
573
+ .get('/moved-permanently-1')
574
+ .expect('Location', '/permanent-location-1')
575
+ .expect(301, done)
576
+ })
580
577
 
581
- it("Should handle Route Parameters redirects properly", function (done) {
578
+ it('Should handle Route Parameters redirects properly', function (done) {
582
579
  const app = createApp(
583
580
  (pageType, params, config, client, { host, next }) => next(),
584
- [{ pageType: "story-page", path: "/*" }],
581
+ [{ pageType: 'story-page', path: '/*' }],
585
582
  { redirectUrls: getRedirectUrl }
586
- );
583
+ )
587
584
  supertest(app)
588
- .get("/india/news/some-slug")
589
- .expect("Location", "/india/some-slug")
590
- .expect(301, done);
591
- });
585
+ .get('/india/news/some-slug')
586
+ .expect('Location', '/india/some-slug')
587
+ .expect(301, done)
588
+ })
592
589
 
593
- it("Should handle multiple Route Parameters redirects properly", function (done) {
590
+ it('Should handle multiple Route Parameters redirects properly', function (done) {
594
591
  const app = createApp(
595
592
  (pageType, params, config, client, { host, next }) => next(),
596
- [{ pageType: "story-page", path: "/*" }],
593
+ [{ pageType: 'story-page', path: '/*' }],
597
594
  { redirectUrls: getRedirectUrl }
598
- );
595
+ )
599
596
  supertest(app)
600
- .get("/india/foo/some-slug/slug")
601
- .expect("Location", "/india/some-slug")
602
- .expect(302, done);
603
- });
597
+ .get('/india/foo/some-slug/slug')
598
+ .expect('Location', '/india/some-slug')
599
+ .expect(302, done)
600
+ })
604
601
 
605
- it("Should handle interchanging route parameter redirects properly", function (done) {
602
+ it('Should handle interchanging route parameter redirects properly', function (done) {
606
603
  const app = createApp(
607
604
  (pageType, params, config, client, { host, next }) => next(),
608
- [{ pageType: "story-page", path: "/*" }],
605
+ [{ pageType: 'story-page', path: '/*' }],
609
606
  { redirectUrls: getRedirectUrl }
610
- );
607
+ )
611
608
  supertest(app)
612
- .get("/foo/something/bar")
613
- .expect("Location", "/bar/something/foo")
614
- .expect(301, done);
615
- });
609
+ .get('/foo/something/bar')
610
+ .expect('Location', '/bar/something/foo')
611
+ .expect(301, done)
612
+ })
616
613
 
617
- it("Should handle external redirects", function (done) {
614
+ it('Should handle external redirects', function (done) {
618
615
  const app = createApp(
619
616
  (pageType, params, config, client, { host, next }) => next(),
620
- [{ pageType: "story-page", path: "/*" }],
617
+ [{ pageType: 'story-page', path: '/*' }],
621
618
  { redirectUrls: getRedirectUrl }
622
- );
619
+ )
623
620
  supertest(app)
624
- .get("/something/new")
625
- .expect("Location", "https://www.google.com/something")
626
- .expect(301, done);
627
- });
621
+ .get('/something/new')
622
+ .expect('Location', 'https://www.google.com/something')
623
+ .expect(301, done)
624
+ })
628
625
 
629
- it("Should handle external redirects with params", function (done) {
626
+ it('Should handle external redirects with params', function (done) {
630
627
  const app = createApp(
631
628
  (pageType, params, config, client, { host, next }) => next(),
632
- [{ pageType: "story-page", path: "/*" }],
629
+ [{ pageType: 'story-page', path: '/*' }],
633
630
  { redirectUrls: getRedirectUrl }
634
- );
631
+ )
635
632
  supertest(app)
636
- .get("/something/new1")
637
- .expect("Location", "https://www.google.com/new1")
638
- .expect(301, done);
639
- });
633
+ .get('/something/new1')
634
+ .expect('Location', 'https://www.google.com/new1')
635
+ .expect(301, done)
636
+ })
640
637
 
641
- it("Should not crash if redirectUrls is not present", function (done) {
642
- const app = createApp(
643
- (pageType, params, config, client, { host, next }) => next(),
644
- [{ pageType: "story-page", path: "/*" }]
645
- );
638
+ it('Should not crash if redirectUrls is not present', function (done) {
639
+ const app = createApp((pageType, params, config, client, { host, next }) => next(), [
640
+ { pageType: 'story-page', path: '/*' }
641
+ ])
646
642
  supertest(app)
647
- .get("/moved-temporarily-1")
648
- .expect("Location", "/temporarily-location-1")
649
- .expect(
650
- "Cache-Control",
651
- "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400"
652
- )
653
- .expect("Vary", /Accept\-Encoding/)
654
- .expect("Surrogate-Key", "sp/42/102")
655
- .expect("Cache-Tag", "sp/42/102")
656
- .expect(302, done);
657
- });
643
+ .get('/moved-temporarily-1')
644
+ .expect('Location', '/temporarily-location-1')
645
+ .expect('Cache-Control', 'public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400')
646
+ .expect('Vary', /Accept\-Encoding/)
647
+ .expect('Cache-Tag', 'sp/42/102')
648
+ .expect(302, done)
649
+ })
658
650
 
659
651
  it("Returns 404 if the route doesn't exist", function (done) {
660
- const app = createApp(
661
- (pageType, params, config, client, { host, next }) => next(),
662
- [{ pageType: "story-page", path: "/*" }]
663
- );
664
- supertest(app).get("/does-not-exist").expect(404, done);
665
- });
666
- });
652
+ const app = createApp((pageType, params, config, client, { host, next }) => next(), [
653
+ { pageType: 'story-page', path: '/*' }
654
+ ])
655
+ supertest(app)
656
+ .get('/does-not-exist')
657
+ .expect(404, done)
658
+ })
659
+ })