@quintype/framework 7.19.0-image-bandwidth-issue.2 → 7.19.0

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/CHANGELOG.md CHANGED
@@ -2,6 +2,34 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [7.19.0](https://github.com/quintype/quintype-node-framework/compare/v7.10.5...v7.19.0) (2023-05-08)
6
+
7
+
8
+ ### Features
9
+
10
+ * **amp:** Decode embed using utf 8 ([#345](https://github.com/quintype/quintype-node-framework/issues/345)) ([4e8a3b3](https://github.com/quintype/quintype-node-framework/commit/4e8a3b38b9be62571f96e69e8b976ff610daf068))
11
+ * remove powered by quintype from the footer ([#334](https://github.com/quintype/quintype-node-framework/issues/334)) ([3dbc1f3](https://github.com/quintype/quintype-node-framework/commit/3dbc1f3144536a439ad0ecaacd2313cb6bb528e1))
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * custom pages cache ([#359](https://github.com/quintype/quintype-node-framework/issues/359)) ([b843967](https://github.com/quintype/quintype-node-framework/commit/b843967fb9126cacc5bf524eb1ca1e2c60c58fdc))
17
+ * Amp chartbeat domain ([#344](https://github.com/quintype/quintype-node-framework/issues/344)) ([cbfd2f1](https://github.com/quintype/quintype-node-framework/commit/cbfd2f1a439fffbd4b9ba619d59df0165005a64a))
18
+ * **amp:** Use correct dates for amp stories ([#338](https://github.com/quintype/quintype-node-framework/issues/338)) ([2182c50](https://github.com/quintype/quintype-node-framework/commit/2182c50fbeb5cc9003d766315bd518bbc287c8ee))
19
+ * **ga:** update title before history push for ga tracking issue ([#347](https://github.com/quintype/quintype-node-framework/issues/347)) ([adb6dc8](https://github.com/quintype/quintype-node-framework/commit/adb6dc8425b097bf9717ea8ba745e69609ccbbb2))
20
+ * package lock ([4d8b44a](https://github.com/quintype/quintype-node-framework/commit/4d8b44a28b65c0c15fcebcc2d7cbe4a9a12c27dd))
21
+ * **redirects:** cache redirects ([#332](https://github.com/quintype/quintype-node-framework/issues/332)) ([ae820eb](https://github.com/quintype/quintype-node-framework/commit/ae820eb5fb205d3ae4ec4771ded953690705a3b9))
22
+ * update version ([4d7166e](https://github.com/quintype/quintype-node-framework/commit/4d7166ea9fdac240e1aeb56883b991b50c1e72db))
23
+
24
+ ### [7.18.11](https://github.com/quintype/quintype-node-framework/compare/v7.18.10...v7.18.11) (2023-04-27)
25
+
26
+
27
+ ### Bug Fixes
28
+
29
+ * custom pages cache ([#359](https://github.com/quintype/quintype-node-framework/issues/359)) ([b843967](https://github.com/quintype/quintype-node-framework/commit/b843967fb9126cacc5bf524eb1ca1e2c60c58fdc))
30
+ * package lock ([4d8b44a](https://github.com/quintype/quintype-node-framework/commit/4d8b44a28b65c0c15fcebcc2d7cbe4a9a12c27dd))
31
+ * update version ([4d7166e](https://github.com/quintype/quintype-node-framework/commit/4d7166ea9fdac240e1aeb56883b991b50c1e72db))
32
+
5
33
  ### [7.18.10](https://github.com/quintype/quintype-node-framework/compare/v7.18.9...v7.18.10) (2023-04-05)
6
34
 
7
35
  ### [7.18.9](https://github.com/quintype/quintype-node-framework/compare/v7.18.1...v7.18.9) (2023-03-14)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/framework",
3
- "version": "7.19.0-image-bandwidth-issue.2",
3
+ "version": "7.19.0",
4
4
  "description": "Libraries to help build Quintype Node.js apps",
5
5
  "main": "index.js",
6
6
  "engines": {
@@ -31,7 +31,7 @@
31
31
  "homepage": "https://github.com/quintype/quintype-node-framework#readme",
32
32
  "dependencies": {
33
33
  "@ampproject/toolbox-optimizer": "2.8.3",
34
- "@quintype/amp": "2.12.0-image-bandwidth-issue.0",
34
+ "@quintype/amp": "^2.10.0",
35
35
  "@quintype/backend": "^2.3.3",
36
36
  "@quintype/components": "^3.3.0",
37
37
  "@quintype/prerender-node": "^3.2.26",
package/server/caching.js CHANGED
@@ -61,5 +61,5 @@ exports.sorterToCacheKey = function sorterToCacheKey(
61
61
  * @returns {string} The cache key
62
62
  */
63
63
  exports.customUrlToCacheKey = function customUrlToCacheKey(publisherId, page) {
64
- return `u/${publisherId}/${page.id}`;
64
+ return `sp/${publisherId}/${page.id}`;
65
65
  };
@@ -20,7 +20,7 @@ exports.addCacheHeadersToResult = function addCacheHeadersToResult({
20
20
  res.setHeader(
21
21
  "Content-Security-Policy",
22
22
  `default-src data: 'unsafe-inline' 'unsafe-eval' https: http:;` +
23
- `script-src data: 'unsafe-inline' 'unsafe-eval' https: http: blob:;` +
23
+ `script-src 'self' https://cdnjs.cloudflare.com;` +
24
24
  `style-src data: 'unsafe-inline' https: http: blob:;` +
25
25
  `img-src data: https: http: blob:;` +
26
26
  `font-src data: https: http:;` +
@@ -60,7 +60,7 @@ exports.addCacheHeadersToResult = function addCacheHeadersToResult({
60
60
  res.setHeader(
61
61
  "Content-Security-Policy",
62
62
  `default-src data: 'unsafe-inline' 'unsafe-eval' https: http:;` +
63
- `script-src data: 'unsafe-inline' 'unsafe-eval' https: http: blob:;` +
63
+ `script-src 'self' https://cdnjs.cloudflare.com;` +
64
64
  `style-src data: 'unsafe-inline' https: http: blob:;` +
65
65
  `img-src data: https: http: blob:;` +
66
66
  `font-src data: https: http:;` +
@@ -80,7 +80,7 @@ exports.addCacheHeadersToResult = function addCacheHeadersToResult({
80
80
  res.setHeader(
81
81
  "Content-Security-Policy",
82
82
  `default-src data: 'unsafe-inline' 'unsafe-eval' https: http:;` +
83
- `script-src data: 'unsafe-inline' 'unsafe-eval' https: http: blob:;` +
83
+ `script-src 'self' https://cdnjs.cloudflare.com;` +
84
84
  `style-src data: 'unsafe-inline' https: http: blob:;` +
85
85
  `img-src data: https: http: blob:;` +
86
86
  `font-src data: https: http:;` +
@@ -15,7 +15,6 @@ const { customUrlToCacheKey } = require("../caching");
15
15
  const { addLightPageHeaders } = require("../impl/light-page-impl");
16
16
  const { getOneSignalScript } = require("./onesignal-script");
17
17
  const { getRedirectUrl } = require("../redirect-url-helper");
18
- const { Story } = require("../impl/api-client-impl");
19
18
 
20
19
  const ABORT_HANDLER = "__ABORT__";
21
20
  function abortHandler() {
@@ -38,7 +37,6 @@ function loadDataForIsomorphicRoute(
38
37
  async function loadDataForEachRoute() {
39
38
  const redirectToLowercaseSlugsValue =
40
39
  typeof redirectToLowercaseSlugs === "function" ? redirectToLowercaseSlugs(config) : redirectToLowercaseSlugs;
41
-
42
40
  for (const match of matchAllRoutes(url.pathname, routes)) {
43
41
  const params = Object.assign({}, url.query, otherParams, match.params);
44
42
  /* On story pages, if the slug contains any capital letters (latin), we want to
@@ -58,7 +56,6 @@ function loadDataForIsomorphicRoute(
58
56
  },
59
57
  };
60
58
  }
61
-
62
59
  const result = await loadData(match.pageType, params, config, client, {
63
60
  host,
64
61
  next: abortHandler,
@@ -71,18 +68,6 @@ function loadDataForIsomorphicRoute(
71
68
 
72
69
  if (result && result.data && result.data[ABORT_HANDLER]) continue;
73
70
 
74
- // Multiple url redirection
75
- const story = result.data.story;
76
- if (story && story.redirect && `/${story.slug}` !== url.path) {
77
- console.log("Inside Redirect IF", url.path);
78
- return {
79
- httpStatusCode: 301,
80
- data: {
81
- location: `/${story.slug}`,
82
- },
83
- };
84
- }
85
-
86
71
  return result;
87
72
  }
88
73
  }
@@ -306,18 +291,8 @@ exports.handleIsomorphicDataLoad = function handleIsomorphicDataLoad(
306
291
  }
307
292
 
308
293
  function returnJson(result) {
309
- const statusCode = result.httpStatusCode || 200;
310
- if (statusCode == 301 && result.data && result.data.location) {
311
- addCacheHeadersToResult({
312
- res: res,
313
- cacheKeys: [customUrlToCacheKey(config["publisher-id"], "redirect")],
314
- cdnProvider: cdnProvider,
315
- config: config,
316
- sMaxAge,
317
- });
318
- return res.redirect(301, result.data.location);
319
- }
320
294
  return new Promise(() => {
295
+ const statusCode = result.httpStatusCode || 200;
321
296
  res.status(statusCode < 500 ? 200 : 500);
322
297
  res.setHeader("Content-Type", "application/json");
323
298
  addCacheHeadersToResult({
@@ -131,8 +131,8 @@ 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", "u/42/101")
135
- .expect("Cache-Tag", "u/42/101")
134
+ .expect("Surrogate-Key", "sp/42/101")
135
+ .expect("Cache-Tag", "sp/42/101")
136
136
  .expect(301, done);
137
137
  });
138
138
 
@@ -149,8 +149,8 @@ describe("Custom Route Handler", function () {
149
149
  "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400"
150
150
  )
151
151
  .expect("Vary", /Accept\-Encoding/)
152
- .expect("Surrogate-Key", "u/42/102")
153
- .expect("Cache-Tag", "u/42/102")
152
+ .expect("Surrogate-Key", "sp/42/102")
153
+ .expect("Cache-Tag", "sp/42/102")
154
154
  .expect(302, done);
155
155
  });
156
156
 
@@ -168,8 +168,8 @@ describe("Custom Route Handler", function () {
168
168
  "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400"
169
169
  )
170
170
  .expect("Vary", "Accept-Encoding")
171
- .expect("Surrogate-Key", "u/42/103")
172
- .expect("Cache-Tag", "u/42/103")
171
+ .expect("Surrogate-Key", "sp/42/103")
172
+ .expect("Cache-Tag", "sp/42/103")
173
173
  .expect(200)
174
174
  .then((res) => {
175
175
  const response = JSON.parse(res.text);
@@ -193,8 +193,8 @@ describe("Custom Route Handler", function () {
193
193
  "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400"
194
194
  )
195
195
  .expect("Vary", "Accept-Encoding")
196
- .expect("Surrogate-Key", "u/42/104")
197
- .expect("Cache-Tag", "u/42/104")
196
+ .expect("Surrogate-Key", "sp/42/104")
197
+ .expect("Cache-Tag", "sp/42/104")
198
198
  .expect(200)
199
199
  .then((res) => {
200
200
  assert.equal(
@@ -263,8 +263,8 @@ describe("Custom Route Handler", function () {
263
263
  "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400"
264
264
  )
265
265
  .expect("Vary", /Accept\-Encoding/)
266
- .expect("Surrogate-Key", "u/42/105")
267
- .expect("Cache-Tag", "u/42/105")
266
+ .expect("Surrogate-Key", "sp/42/105")
267
+ .expect("Cache-Tag", "sp/42/105")
268
268
  .expect(301, done);
269
269
  });
270
270
 
@@ -280,8 +280,8 @@ describe("Custom Route Handler", function () {
280
280
  "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400"
281
281
  )
282
282
  .expect("Vary", /Accept\-Encoding/)
283
- .expect("Surrogate-Key", "u/42/105")
284
- .expect("Cache-Tag", "u/42/105")
283
+ .expect("Surrogate-Key", "sp/42/105")
284
+ .expect("Cache-Tag", "sp/42/105")
285
285
  .expect("Content-Type", "text/plain; charset=utf-8")
286
286
  .expect(200, done);
287
287
  });
@@ -298,8 +298,8 @@ describe("Custom Route Handler", function () {
298
298
  "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400"
299
299
  )
300
300
  .expect("Vary", "Accept-Encoding")
301
- .expect("Surrogate-Key", "u/42/104")
302
- .expect("Cache-Tag", "u/42/104")
301
+ .expect("Surrogate-Key", "sp/42/104")
302
+ .expect("Cache-Tag", "sp/42/104")
303
303
  .expect("Content-Type", "text/html; charset=utf-8")
304
304
  .expect(200, done);
305
305
  });
@@ -98,7 +98,9 @@ describe("Isomorphic Data Load", function () {
98
98
  });
99
99
 
100
100
  it("returns an appVersion on every response", function (done) {
101
- const app = createApp((pageType, params, config, client) => Promise.resolve({ data: { pageType } }));
101
+ const app = createApp((pageType, params, config, client) =>
102
+ Promise.resolve({})
103
+ );
102
104
 
103
105
  supertest(app)
104
106
  .get("/route-data.json?path=%2F")
@@ -13,10 +13,6 @@ function getClientStub(hostname) {
13
13
  foo: "bar",
14
14
  "sketches-host": "https://www.foo.com",
15
15
  }),
16
- getStoryBySlug: (slug) =>
17
- Promise.resolve({
18
- story: { slug: slug, id: "123", redirect: slug === "foo-bar" ? true : false },
19
- }),
20
16
  baseUrl: "https://www.foo.com",
21
17
  };
22
18
  }
@@ -55,22 +51,9 @@ function createApp(loadData, routes, opts = {}, app = express()) {
55
51
  }
56
52
 
57
53
  describe("Isomorphic Handler", function () {
58
- it("when the story headline is changed, it redirects story to updated story url", (done) => {
59
- const app = createApp(
60
- (pageType, params, config, client, { host }) =>
61
- Promise.resolve({
62
- pageType,
63
- data: { text: "foobar", host, location: "/foobar", story: { redirect: true, slug: "foo-bar" } },
64
- }),
65
- [{ pageType: "story-page", path: "/foobar", params: { storySlug: "foo-bar" } }]
66
- );
67
- supertest(app).get("/foobar").expect("Location", "/foo-bar").expect(301, done);
68
- });
69
-
70
54
  it("Renders the page if the route matches", function (done) {
71
55
  const app = createApp(
72
- (pageType, params, config, client, { host }) =>
73
- Promise.resolve({ pageType, data: { text: "foobar", host } }),
56
+ (pageType, params, config, client, { host }) => Promise.resolve({ pageType, data: { text: "foobar", host } }),
74
57
  [{ pageType: "home-page", path: "/", exact: true }]
75
58
  );
76
59
 
@@ -80,10 +63,7 @@ describe("Isomorphic Handler", function () {
80
63
  .expect(200)
81
64
  .then((res) => {
82
65
  const response = JSON.parse(res.text);
83
- assert.equal(
84
- '<div data-page-type="home-page">foobar</div>',
85
- response.content
86
- );
66
+ assert.equal('<div data-page-type="home-page">foobar</div>', response.content);
87
67
  assert.equal("foobar", response.store.qt.data.text);
88
68
  assert.equal("127.0.0.1", response.store.qt.data.host);
89
69
  assert.equal("home-page", response.store.qt.pageType);
@@ -93,8 +73,7 @@ describe("Isomorphic Handler", function () {
93
73
 
94
74
  it("Accepts an async pickComponent function", function (done) {
95
75
  const app = createApp(
96
- (pageType, params, config, client, { host }) =>
97
- Promise.resolve({ pageType, data: { text: "foobar" } }),
76
+ (pageType, params, config, client, { host }) => Promise.resolve({ pageType, data: { text: "foobar" } }),
98
77
  [{ pageType: "home-page", path: "/" }],
99
78
  {
100
79
  pickComponent: (pageType) => Promise.resolve(pickComponent(pageType)),
@@ -107,18 +86,14 @@ describe("Isomorphic Handler", function () {
107
86
  .expect(200)
108
87
  .then((res) => {
109
88
  const response = JSON.parse(res.text);
110
- assert.equal(
111
- '<div data-page-type="home-page">foobar</div>',
112
- response.content
113
- );
89
+ assert.equal('<div data-page-type="home-page">foobar</div>', response.content);
114
90
  })
115
91
  .then(done);
116
92
  });
117
93
 
118
94
  it("Passes all URL parameters to the load data function", function (done) {
119
95
  const app = createApp(
120
- (pageType, params, config, client) =>
121
- Promise.resolve({ pageType, data: { text: params.text } }),
96
+ (pageType, params, config, client) => Promise.resolve({ pageType, data: { text: params.text } }),
122
97
  [{ pageType: "home-page", path: "/" }]
123
98
  );
124
99
 
@@ -136,8 +111,7 @@ describe("Isomorphic Handler", function () {
136
111
  describe("preloading", function () {
137
112
  it("preloads the app.js", function (done) {
138
113
  const app = createApp(
139
- (pageType, params, config, client) =>
140
- Promise.resolve({ pageType, data: { text: "foobar" } }),
114
+ (pageType, params, config, client) => Promise.resolve({ pageType, data: { text: "foobar" } }),
141
115
  [{ pageType: "home-page", path: "/" }],
142
116
  {
143
117
  preloadJs: true,
@@ -171,10 +145,7 @@ describe("Isomorphic Handler", function () {
171
145
  .expect(404)
172
146
  .then((res) => {
173
147
  const response = JSON.parse(res.text);
174
- assert.equal(
175
- '<div data-page-type="not-found">foobar</div>',
176
- response.content
177
- );
148
+ assert.equal('<div data-page-type="not-found">foobar</div>', response.content);
178
149
  assert.equal(false, response.store.qt.disableIsomorphicComponent);
179
150
  assert.equal("127.0.0.1", response.store.qt.data.host);
180
151
  })
@@ -202,10 +173,7 @@ describe("Isomorphic Handler", function () {
202
173
  .expect(500)
203
174
  .then((res) => {
204
175
  const response = JSON.parse(res.text);
205
- assert.equal(
206
- '<div data-page-type="not-found">foobar</div>',
207
- response.content
208
- );
176
+ assert.equal('<div data-page-type="not-found">foobar</div>', response.content);
209
177
  assert.equal(true, response.store.qt.disableIsomorphicComponent);
210
178
  })
211
179
  .then(done, done);
@@ -240,10 +208,7 @@ describe("Isomorphic Handler", function () {
240
208
  supertest(app)
241
209
  .get("/")
242
210
  .expect("Content-Type", /html/)
243
- .expect(
244
- "Cache-Control",
245
- "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400"
246
- )
211
+ .expect("Cache-Control", "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400")
247
212
  .expect("Vary", "Accept-Encoding")
248
213
  .expect("Surrogate-Key", "foo bar")
249
214
  .expect("Cache-Tag", "foo,bar")
@@ -252,8 +217,7 @@ describe("Isomorphic Handler", function () {
252
217
 
253
218
  it("it redirects on a 301", function (done) {
254
219
  const app = createApp(
255
- (pageType, params, config, client) =>
256
- Promise.resolve({ httpStatusCode: 301, data: { location: "/foobar" } }),
220
+ (pageType, params, config, client) => Promise.resolve({ httpStatusCode: 301, data: { location: "/foobar" } }),
257
221
  [{ pageType: "home-page", path: "/" }]
258
222
  );
259
223
 
@@ -262,8 +226,7 @@ describe("Isomorphic Handler", function () {
262
226
 
263
227
  it("returns a 500 if render layout crashes", function (done) {
264
228
  const app = createApp(
265
- (pageType, params, config, client) =>
266
- Promise.resolve({ pageType, data: { text: "foobar" } }),
229
+ (pageType, params, config, client) => Promise.resolve({ pageType, data: { text: "foobar" } }),
267
230
  [{ pageType: "home-page", path: "/" }],
268
231
  {
269
232
  renderLayout: () => {
@@ -283,8 +246,7 @@ describe("Isomorphic Handler", function () {
283
246
  });
284
247
 
285
248
  const app = createApp(
286
- (pageType, params, config, client) =>
287
- Promise.resolve({ pageType, data: { text: "foobar" } }),
249
+ (pageType, params, config, client) => Promise.resolve({ pageType, data: { text: "foobar" } }),
288
250
  [{ pageType: "home-page", path: "/" }],
289
251
  {
290
252
  prerenderServiceUrl: "http://localhost:4000",
@@ -353,10 +315,7 @@ describe("Isomorphic Handler", function () {
353
315
  .expect(404)
354
316
  .then((res) => {
355
317
  const response = JSON.parse(res.text);
356
- assert.equal(
357
- '<div data-page-type="not-found">foobar</div>',
358
- response.content
359
- );
318
+ assert.equal('<div data-page-type="not-found">foobar</div>', response.content);
360
319
  assert.equal(false, response.store.qt.disableIsomorphicComponent);
361
320
  assert.equal("127.0.0.1", response.store.qt.data.host);
362
321
  })
@@ -365,8 +324,7 @@ describe("Isomorphic Handler", function () {
365
324
 
366
325
  it("Allows bypassing even data.abort is set", function (done) {
367
326
  const app = createApp(
368
- (pageType, params, config, client, { next }) =>
369
- next().then((n) => ({ data: n })),
327
+ (pageType, params, config, client, { next }) => next().then((n) => ({ data: n })),
370
328
  [{ pageType: "home-page", path: "/skip", exact: true }],
371
329
  {
372
330
  loadErrorData: (err, config, client, { host }) => ({
@@ -383,10 +341,7 @@ describe("Isomorphic Handler", function () {
383
341
  .expect(404)
384
342
  .then((res) => {
385
343
  const response = JSON.parse(res.text);
386
- assert.equal(
387
- '<div data-page-type="not-found">foobar</div>',
388
- response.content
389
- );
344
+ assert.equal('<div data-page-type="not-found">foobar</div>', response.content);
390
345
  assert.equal(false, response.store.qt.disableIsomorphicComponent);
391
346
  assert.equal("127.0.0.1", response.store.qt.data.host);
392
347
  })
@@ -399,9 +354,7 @@ describe("Isomorphic Handler", function () {
399
354
  { pageType: "home-page", path: "/" },
400
355
  ];
401
356
  const dataLoader = (pageType, _1, _2, _3, { host, next }) =>
402
- pageType === "skip"
403
- ? next()
404
- : Promise.resolve({ pageType, data: { text: "foobar", host } });
357
+ pageType === "skip" ? next() : Promise.resolve({ pageType, data: { text: "foobar", host } });
405
358
 
406
359
  const app = createApp(dataLoader, overlappingRoutes);
407
360
 
@@ -411,10 +364,7 @@ describe("Isomorphic Handler", function () {
411
364
  .expect(200)
412
365
  .then((res) => {
413
366
  const response = JSON.parse(res.text);
414
- assert.equal(
415
- '<div data-page-type="home-page">foobar</div>',
416
- response.content
417
- );
367
+ assert.equal('<div data-page-type="home-page">foobar</div>', response.content);
418
368
  assert.equal("foobar", response.store.qt.data.text);
419
369
  assert.equal("127.0.0.1", response.store.qt.data.host);
420
370
  assert.equal("home-page", response.store.qt.pageType);
@@ -425,8 +375,7 @@ describe("Isomorphic Handler", function () {
425
375
 
426
376
  it("Passes the primaryHostUrl and currentHostUrl to the render", function (done) {
427
377
  const app = createApp(
428
- (pageType, params, config, client, { host }) =>
429
- Promise.resolve({ pageType, data: { text: "foobar", host } }),
378
+ (pageType, params, config, client, { host }) => Promise.resolve({ pageType, data: { text: "foobar", host } }),
430
379
  [{ pageType: "home-page", path: "/" }]
431
380
  );
432
381
 
@@ -461,10 +410,7 @@ describe("Isomorphic Handler", function () {
461
410
  .expect("Content-Type", /html/)
462
411
  .expect(200)
463
412
  .then((res) => {
464
- assert.equal(
465
- `http://127.0.0.1/amp/story/%2Ffoo%2Fbar`,
466
- res.get("X-QT-Light-Pages-Url")
467
- );
413
+ assert.equal(`http://127.0.0.1/amp/story/%2Ffoo%2Fbar`, res.get("X-QT-Light-Pages-Url"));
468
414
  })
469
415
  .then(done);
470
416
  });
@@ -487,10 +433,7 @@ describe("Isomorphic Handler", function () {
487
433
  .expect("Content-Type", /html/)
488
434
  .expect(200)
489
435
  .then((res) => {
490
- assert.equal(
491
- `http://127.0.0.1/amp/story/%2Ffoo%2Fbar`,
492
- res.get("X-QT-Light-Pages-Url")
493
- );
436
+ assert.equal(`http://127.0.0.1/amp/story/%2Ffoo%2Fbar`, res.get("X-QT-Light-Pages-Url"));
494
437
  })
495
438
  .then(done);
496
439
  });
@@ -505,8 +448,7 @@ describe("Isomorphic Handler", function () {
505
448
  [{ pageType: "story-page", path: "/*/:storySlug" }],
506
449
  {
507
450
  lightPages: () => false,
508
- renderLightPage: (req, res, result) =>
509
- res.send("<h1> Amp Page </h1>"),
451
+ renderLightPage: (req, res, result) => res.send("<h1> Amp Page </h1>"),
510
452
  shouldEncodeAmpUri: true,
511
453
  }
512
454
  );
@@ -569,10 +511,7 @@ describe("Isomorphic Handler", function () {
569
511
  .then((res) => {
570
512
  const cacheControl = res.header["cache-control"];
571
513
  const cacheTag = res.header["cache-tag"];
572
- assert.equal(
573
- cacheControl,
574
- "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400"
575
- );
514
+ assert.equal(cacheControl, "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400");
576
515
  assert.equal(cacheTag, "c/1/abcdefgh");
577
516
  })
578
517
  .then(done);
@@ -595,10 +534,7 @@ describe("Isomorphic Handler", function () {
595
534
  .then((res) => {
596
535
  const cacheControl = res.header["cache-control"];
597
536
  const cacheTag = res.header["cache-tag"];
598
- assert.equal(
599
- cacheControl,
600
- "public,max-age=15,s-maxage=60,stale-while-revalidate=150,stale-if-error=3600"
601
- );
537
+ assert.equal(cacheControl, "public,max-age=15,s-maxage=60,stale-while-revalidate=150,stale-if-error=3600");
602
538
  assert.equal(cacheTag, undefined);
603
539
  })
604
540
  .then(done);
@@ -632,7 +568,7 @@ describe("Isomorphic Handler", function () {
632
568
  assert.equal(
633
569
  contentSecurityPolicy,
634
570
  `default-src data: 'unsafe-inline' 'unsafe-eval' https: http:;` +
635
- `script-src data: 'unsafe-inline' 'unsafe-eval' https: http: blob:;` +
571
+ `script-src 'self' https://cdnjs.cloudflare.com;` +
636
572
  `style-src data: 'unsafe-inline' https: http: blob:;` +
637
573
  `img-src data: https: http: blob:;` +
638
574
  `font-src data: https: http:;` +
@@ -667,19 +603,13 @@ describe("Isomorphic Handler", function () {
667
603
  const edgeCacheControl = res.header["edge-control"];
668
604
  const edgeCacheTag = res.header["edge-cache-tag"];
669
605
  const contentSecurityPolicy = res.header["content-security-policy"];
670
- assert.equal(
671
- cacheControl,
672
- "public,max-age=15,s-maxage=60,stale-while-revalidate=150,stale-if-error=3600"
673
- );
674
- assert.equal(
675
- edgeCacheControl,
676
- "public,maxage=60,stale-while-revalidate=150,stale-if-error=3600"
677
- );
606
+ assert.equal(cacheControl, "public,max-age=15,s-maxage=60,stale-while-revalidate=150,stale-if-error=3600");
607
+ assert.equal(edgeCacheControl, "public,maxage=60,stale-while-revalidate=150,stale-if-error=3600");
678
608
  assert.equal(edgeCacheTag, undefined);
679
609
  assert.equal(
680
610
  contentSecurityPolicy,
681
611
  `default-src data: 'unsafe-inline' 'unsafe-eval' https: http:;` +
682
- `script-src data: 'unsafe-inline' 'unsafe-eval' https: http: blob:;` +
612
+ `script-src 'self' https://cdnjs.cloudflare.com;` +
683
613
  `style-src data: 'unsafe-inline' https: http: blob:;` +
684
614
  `img-src data: https: http: blob:;` +
685
615
  `font-src data: https: http:;` +
@@ -714,19 +644,13 @@ describe("Isomorphic Handler", function () {
714
644
  const edgeCacheControl = res.header["edge-control"];
715
645
  const edgeCacheTag = res.header["edge-cache-tag"];
716
646
  const contentSecurityPolicy = res.header["content-security-policy"];
717
- assert.equal(
718
- cacheControl,
719
- "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400"
720
- );
721
- assert.equal(
722
- edgeCacheControl,
723
- "public,maxage=900,stale-while-revalidate=1000,stale-if-error=14400"
724
- );
647
+ assert.equal(cacheControl, "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400");
648
+ assert.equal(edgeCacheControl, "public,maxage=900,stale-while-revalidate=1000,stale-if-error=14400");
725
649
  assert.equal(edgeCacheTag, "c/1/abcdefgh");
726
650
  assert.equal(
727
651
  contentSecurityPolicy,
728
652
  `default-src data: 'unsafe-inline' 'unsafe-eval' https: http:;` +
729
- `script-src data: 'unsafe-inline' 'unsafe-eval' https: http: blob:;` +
653
+ `script-src 'self' https://cdnjs.cloudflare.com;` +
730
654
  `style-src data: 'unsafe-inline' https: http: blob:;` +
731
655
  `img-src data: https: http: blob:;` +
732
656
  `font-src data: https: http:;` +
@@ -761,19 +685,13 @@ describe("Isomorphic Handler", function () {
761
685
  const edgeCacheControl = res.header["edge-control"];
762
686
  const edgeCacheTag = res.header["edge-cache-tag"];
763
687
  const contentSecurityPolicy = res.header["content-security-policy"];
764
- assert.equal(
765
- cacheControl,
766
- "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400"
767
- );
768
- assert.equal(
769
- edgeCacheControl,
770
- "public,maxage=900,stale-while-revalidate=1000,stale-if-error=14400"
771
- );
688
+ assert.equal(cacheControl, "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400");
689
+ assert.equal(edgeCacheControl, "public,maxage=900,stale-while-revalidate=1000,stale-if-error=14400");
772
690
  assert.equal(edgeCacheTag, "c/1/abcdefgh");
773
691
  assert.equal(
774
692
  contentSecurityPolicy,
775
693
  `default-src data: 'unsafe-inline' 'unsafe-eval' https: http:;` +
776
- `script-src data: 'unsafe-inline' 'unsafe-eval' https: http: blob:;` +
694
+ `script-src 'self' https://cdnjs.cloudflare.com;` +
777
695
  `style-src data: 'unsafe-inline' https: http: blob:;` +
778
696
  `img-src data: https: http: blob:;` +
779
697
  `font-src data: https: http:;` +
@@ -828,10 +746,7 @@ describe("Isomorphic Handler", function () {
828
746
  .expect(200)
829
747
  .then((res) => {
830
748
  const cacheControl = res.header["cache-control"];
831
- assert.equal(
832
- cacheControl,
833
- "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400"
834
- );
749
+ assert.equal(cacheControl, "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400");
835
750
  })
836
751
  .then(done);
837
752
  });
@@ -933,8 +848,7 @@ describe("Isomorphic Handler", function () {
933
848
  const app = express();
934
849
  mountQuintypeAt(app, "/foo");
935
850
  createApp(
936
- (pageType, params, config, client, { host }) =>
937
- Promise.resolve({ pageType, data: { text: "foobar", host } }),
851
+ (pageType, params, config, client, { host }) => Promise.resolve({ pageType, data: { text: "foobar", host } }),
938
852
  [{ pageType: "home-page", path: "/", exact: true }],
939
853
  {},
940
854
  app
@@ -946,10 +860,7 @@ describe("Isomorphic Handler", function () {
946
860
  .expect(200)
947
861
  .then((res) => {
948
862
  const response = JSON.parse(res.text);
949
- assert.equal(
950
- '<div data-page-type="home-page">foobar</div>',
951
- response.content
952
- );
863
+ assert.equal('<div data-page-type="home-page">foobar</div>', response.content);
953
864
  assert.equal("foobar", response.store.qt.data.text);
954
865
  assert.equal("127.0.0.1", response.store.qt.data.host);
955
866
  assert.equal("home-page", response.store.qt.pageType);
@@ -960,8 +871,7 @@ describe("Isomorphic Handler", function () {
960
871
  const app = express();
961
872
  mountQuintypeAt(app, "/foo");
962
873
  createApp(
963
- (pageType, params, config, client, { host }) =>
964
- Promise.resolve({ pageType, data: { text: "foobar", host } }),
874
+ (pageType, params, config, client, { host }) => Promise.resolve({ pageType, data: { text: "foobar", host } }),
965
875
  [{ pageType: "home-page", path: "/", exact: true }],
966
876
  {},
967
877
  app
@@ -974,8 +884,7 @@ describe("Isomorphic Handler", function () {
974
884
  const app = express();
975
885
  mountQuintypeAt(app, (hostname) => `/${hostname}`);
976
886
  createApp(
977
- (pageType, params, config, client, { host }) =>
978
- Promise.resolve({ pageType, data: { text: "foobar", host } }),
887
+ (pageType, params, config, client, { host }) => Promise.resolve({ pageType, data: { text: "foobar", host } }),
979
888
  [{ pageType: "home-page", path: "/", exact: true }],
980
889
  {},
981
890
  app
@@ -987,10 +896,7 @@ describe("Isomorphic Handler", function () {
987
896
  .expect(200)
988
897
  .then((res) => {
989
898
  const response = JSON.parse(res.text);
990
- assert.equal(
991
- '<div data-page-type="home-page">foobar</div>',
992
- response.content
993
- );
899
+ assert.equal('<div data-page-type="home-page">foobar</div>', response.content);
994
900
  assert.equal("foobar", response.store.qt.data.text);
995
901
  assert.equal("127.0.0.1", response.store.qt.data.host);
996
902
  assert.equal("home-page", response.store.qt.pageType);
@@ -1001,8 +907,7 @@ describe("Isomorphic Handler", function () {
1001
907
  const app = express();
1002
908
  mountQuintypeAt(app, (hostname) => undefined);
1003
909
  createApp(
1004
- (pageType, params, config, client, { host }) =>
1005
- Promise.resolve({ pageType, data: { text: "foobar", host } }),
910
+ (pageType, params, config, client, { host }) => Promise.resolve({ pageType, data: { text: "foobar", host } }),
1006
911
  [{ pageType: "home-page", path: "/", exact: true }],
1007
912
  {},
1008
913
  app
@@ -1014,10 +919,7 @@ describe("Isomorphic Handler", function () {
1014
919
  .expect(200)
1015
920
  .then((res) => {
1016
921
  const response = JSON.parse(res.text);
1017
- assert.equal(
1018
- '<div data-page-type="home-page">foobar</div>',
1019
- response.content
1020
- );
922
+ assert.equal('<div data-page-type="home-page">foobar</div>', response.content);
1021
923
  assert.equal("foobar", response.store.qt.data.text);
1022
924
  assert.equal("127.0.0.1", response.store.qt.data.host);
1023
925
  assert.equal("home-page", response.store.qt.pageType);
@@ -651,8 +651,8 @@ describe("Redirect Routes Handler", function () {
651
651
  "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400"
652
652
  )
653
653
  .expect("Vary", /Accept\-Encoding/)
654
- .expect("Surrogate-Key", "u/42/102")
655
- .expect("Cache-Tag", "u/42/102")
654
+ .expect("Surrogate-Key", "sp/42/102")
655
+ .expect("Cache-Tag", "sp/42/102")
656
656
  .expect(302, done);
657
657
  });
658
658
 
@@ -678,7 +678,7 @@ describe("ApiClient", function () {
678
678
  describe("Custom urls", function () {
679
679
  it("returns cache keys", function () {
680
680
  const page = CustomPath.build({ id: 101 });
681
- assert.deepStrictEqual(["u/1/101"], page.cacheKeys(1));
681
+ assert.deepStrictEqual(["sp/1/101"], page.cacheKeys(1));
682
682
  });
683
683
 
684
684
  it("returns cache keys as null if page is invalid", function () {