@quintype/framework 7.28.4-image-below-fold.2 → 7.29.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,13 @@
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.29.0](https://github.com/quintype/quintype-node-framework/compare/v7.28.3...v7.29.0) (2024-07-15)
6
+
7
+
8
+ ### Features
9
+
10
+ * Add support for 410 Gone URL ([#431](https://github.com/quintype/quintype-node-framework/issues/431)) ([8820a42](https://github.com/quintype/quintype-node-framework/commit/8820a42a51f0a22f598d4562c0b2a154fce8931a))
11
+
5
12
  ### [7.28.3](https://github.com/quintype/quintype-node-framework/compare/v7.28.2...v7.28.3) (2024-06-13)
6
13
 
7
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/framework",
3
- "version": "7.28.4-image-below-fold.2",
3
+ "version": "7.29.0",
4
4
  "description": "Libraries to help build Quintype Node.js apps",
5
5
  "main": "index.js",
6
6
  "engines": {
@@ -192,7 +192,6 @@ exports.handleIsomorphicShell = async function handleIsomorphicShell(
192
192
  };
193
193
 
194
194
  function createStoreFromResult(url, result, opts = {}) {
195
- const isBotRequest = _.get(url, "query.botrequest", false);
196
195
  const qt = {
197
196
  pageType: result.pageType || opts.defaultPageType,
198
197
  subPageType: result.subPageType,
@@ -200,8 +199,6 @@ function createStoreFromResult(url, result, opts = {}) {
200
199
  currentPath: `${url.pathname}${url.search || ""}`,
201
200
  currentHostUrl: result.currentHostUrl,
202
201
  primaryHostUrl: result.primaryHostUrl,
203
- isBotRequest: isBotRequest,
204
- belowFoldImgMargin: opts.belowFoldImgMargin,
205
202
  };
206
203
  return createBasicStore(result, qt, opts);
207
204
  }
@@ -464,7 +461,6 @@ exports.handleIsomorphicRoute = function handleIsomorphicRoute(
464
461
  ampPageBasePath,
465
462
  externalIdPattern,
466
463
  enableExternalStories,
467
- belowFoldImgMargin,
468
464
  }
469
465
  ) {
470
466
  const url = urlLib.parse(req.url, true);
@@ -485,10 +481,8 @@ exports.handleIsomorphicRoute = function handleIsomorphicRoute(
485
481
  }
486
482
  const seoInstance = getSeoInstance(seo, config, result.pageType);
487
483
  const seoTags = seoInstance && seoInstance.getMetaTags(config, result.pageType || match.pageType, result, { url });
488
-
489
484
  const store = createStoreFromResult(url, result, {
490
485
  disableIsomorphicComponent: statusCode != 200,
491
- belowFoldImgMargin,
492
486
  });
493
487
 
494
488
  if (lightPages) {
@@ -1,73 +1,77 @@
1
- const url = require("url");
2
- const logError = require("./logger").error;
3
- const { match, compile } = require("path-to-regexp");
1
+ const url = require('url')
2
+ const logError = require('./logger').error
3
+ const { match, compile } = require('path-to-regexp')
4
4
 
5
- function isUrl(url) {
5
+ function isUrl (url) {
6
6
  try {
7
- return new URL(url);
7
+ return new URL(url)
8
8
  } catch (err) {
9
- return false;
9
+ return false
10
10
  }
11
11
  }
12
12
 
13
- function processRedirects(req, res, next, sourceUrlArray, urls) {
14
- const query = url.parse(req.url, true) || {};
15
- const search = query.search || "";
13
+ function processRedirects (req, res, next, sourceUrlArray, urls) {
14
+ const query = url.parse(req.url, true) || {}
15
+ const search = query.search || ''
16
16
 
17
- sourceUrlArray.some((sourceUrl) => {
17
+ sourceUrlArray.some(sourceUrl => {
18
18
  try {
19
+ const statusCode = parseInt(urls[sourceUrl].statusCode, 10)
20
+ if (statusCode === 410) {
21
+ res.sendStatus(410)
22
+ return true
23
+ }
19
24
  if (urls[sourceUrl]) {
20
- const destinationPath = urls[sourceUrl].destinationUrl;
25
+ const destinationPath = urls[sourceUrl].destinationUrl
21
26
  const extractedSourceUrl = match(sourceUrl, {
22
- decode: decodeURIComponent,
23
- });
24
- const destinationUrl = isUrl(destinationPath);
27
+ decode: decodeURIComponent
28
+ })
29
+ const destinationUrl = isUrl(destinationPath)
25
30
  if (extractedSourceUrl) {
26
- let extractedDestinationUrl;
31
+ let extractedDestinationUrl
27
32
  if (destinationUrl) {
28
33
  extractedDestinationUrl = compile(destinationUrl.pathname, {
29
- encode: encodeURIComponent,
30
- });
34
+ encode: encodeURIComponent
35
+ })
31
36
  } else {
32
37
  extractedDestinationUrl = compile(destinationPath, {
33
- encode: encodeURIComponent,
34
- });
38
+ encode: encodeURIComponent
39
+ })
35
40
  }
36
- const dynamicKeys = extractedSourceUrl(req.path);
37
- const compiledPath = dynamicKeys && extractedDestinationUrl(dynamicKeys.params);
41
+ const dynamicKeys = extractedSourceUrl(req.path)
42
+ const compiledPath = dynamicKeys && extractedDestinationUrl(dynamicKeys.params)
38
43
  if (compiledPath) {
39
- const validStatusCodes = { 301: "max-age=604800", 302: "max-age=86400" };
40
- const statusCode = parseInt(urls[sourceUrl].statusCode, 10);
41
- const cacheValue = validStatusCodes[statusCode];
44
+ const validStatusCodes = { 301: 'max-age=604800', 302: 'max-age=86400' }
45
+ const cacheValue = validStatusCodes[statusCode]
42
46
  if (cacheValue) {
43
- res.set("cache-control", `public,${cacheValue}`);
47
+ res.set('cache-control', `public,${cacheValue}`)
44
48
  }
45
49
  res.redirect(
46
50
  statusCode,
47
51
  destinationUrl
48
52
  ? `${destinationUrl.protocol}//${destinationUrl.hostname}${compiledPath}${search}`
49
53
  : `${compiledPath}${search}`
50
- );
51
- return true;
54
+ )
55
+ return true
52
56
  }
53
57
  }
54
58
  }
55
59
  } catch (err) {
56
- console.log(`Redirection error on ${req.host}-----`, err);
60
+ console.log(`Redirection error on ${req.host}-----`, err)
57
61
  }
58
- });
62
+ })
59
63
  }
60
64
 
61
- exports.getRedirectUrl = async function getRedirectUrl(req, res, next, { redirectUrls, config }) {
62
- let sourceUrls;
63
- if (typeof redirectUrls === "function") {
64
- const redirectUrlsList = await redirectUrls(config);
65
- sourceUrls = Object.keys(redirectUrlsList);
65
+ exports.getRedirectUrl = async function getRedirectUrl (req, res, next, { redirectUrls, config }) {
66
+ let sourceUrls
67
+ if (typeof redirectUrls === 'function') {
68
+ const redirectUrlsList = await redirectUrls(config)
69
+ sourceUrls = Object.keys(redirectUrlsList)
66
70
  if (sourceUrls.length > 0) {
67
- processRedirects(req, res, next, sourceUrls, redirectUrlsList);
71
+ processRedirects(req, res, next, sourceUrls, redirectUrlsList)
68
72
  }
69
73
  } else if (redirectUrls) {
70
- sourceUrls = Object.keys(redirectUrls);
71
- sourceUrls.length > 0 && processRedirects(req, res, next, sourceUrls, redirectUrls);
74
+ sourceUrls = Object.keys(redirectUrls)
75
+ sourceUrls.length > 0 && processRedirects(req, res, next, sourceUrls, redirectUrls)
72
76
  }
73
- };
77
+ }
package/server/routes.js CHANGED
@@ -355,7 +355,6 @@ exports.isomorphicRoutes = function isomorphicRoutes(
355
355
  webengageConfig = {},
356
356
  externalIdPattern = "",
357
357
  enableExternalStories = false,
358
- belowFoldImgMargin,
359
358
  }
360
359
  ) {
361
360
  const withConfig = withConfigPartial(getClient, logError, publisherConfig, configWrapper);
@@ -548,7 +547,6 @@ exports.isomorphicRoutes = function isomorphicRoutes(
548
547
  ampPageBasePath,
549
548
  externalIdPattern,
550
549
  enableExternalStories,
551
- belowFoldImgMargin,
552
550
  })
553
551
  );
554
552