@quintype/framework 7.19.19 → 7.19.20

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,8 @@
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.20](https://github.com/quintype/quintype-node-framework/compare/v7.19.19...v7.19.20) (2023-07-24)
6
+
5
7
  ### [7.19.19](https://github.com/quintype/quintype-node-framework/compare/v7.19.18...v7.19.19) (2023-07-24)
6
8
 
7
9
  ### [7.19.18](https://github.com/quintype/quintype-node-framework/compare/v7.19.17...v7.19.18) (2023-07-17)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/framework",
3
- "version": "7.19.19",
3
+ "version": "7.19.20",
4
4
  "description": "Libraries to help build Quintype Node.js apps",
5
5
  "main": "index.js",
6
6
  "engines": {
@@ -15,41 +15,45 @@ function processRedirects(req, res, next, sourceUrlArray, urls) {
15
15
  const search = query.search || "";
16
16
 
17
17
  sourceUrlArray.some((sourceUrl) => {
18
- if (urls[sourceUrl]) {
19
- const destinationPath = urls[sourceUrl].destinationUrl;
20
- const extractedSourceUrl = match(sourceUrl, {
21
- decode: decodeURIComponent,
22
- });
23
- const destinationUrl = isUrl(destinationPath);
24
- if (extractedSourceUrl) {
25
- let extractedDestinationUrl;
26
- if (destinationUrl) {
27
- extractedDestinationUrl = compile(destinationUrl.pathname, {
28
- encode: encodeURIComponent,
29
- });
30
- } else {
31
- extractedDestinationUrl = compile(destinationPath, {
32
- encode: encodeURIComponent,
33
- });
34
- }
35
- const dynamicKeys = extractedSourceUrl(req.path);
36
- const compiledPath = dynamicKeys && extractedDestinationUrl(dynamicKeys.params);
37
- if (compiledPath) {
38
- const validStatusCodes = { 301: "max-age=604800", 302: "max-age=86400" };
39
- const statusCode = parseInt(urls[sourceUrl].statusCode, 10);
40
- const cacheValue = validStatusCodes[statusCode];
41
- if (cacheValue) {
42
- res.set("cache-control", `public,${cacheValue}`);
18
+ try {
19
+ if (urls[sourceUrl]) {
20
+ const destinationPath = urls[sourceUrl].destinationUrl;
21
+ const extractedSourceUrl = match(sourceUrl, {
22
+ decode: decodeURIComponent,
23
+ });
24
+ const destinationUrl = isUrl(destinationPath);
25
+ if (extractedSourceUrl) {
26
+ let extractedDestinationUrl;
27
+ if (destinationUrl) {
28
+ extractedDestinationUrl = compile(destinationUrl.pathname, {
29
+ encode: encodeURIComponent,
30
+ });
31
+ } else {
32
+ extractedDestinationUrl = compile(destinationPath, {
33
+ encode: encodeURIComponent,
34
+ });
35
+ }
36
+ const dynamicKeys = extractedSourceUrl(req.path);
37
+ const compiledPath = dynamicKeys && extractedDestinationUrl(dynamicKeys.params);
38
+ 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];
42
+ if (cacheValue) {
43
+ res.set("cache-control", `public,${cacheValue}`);
44
+ }
45
+ res.redirect(
46
+ statusCode,
47
+ destinationUrl
48
+ ? `${destinationUrl.protocol}//${destinationUrl.hostname}${compiledPath}${search}`
49
+ : `${compiledPath}${search}`
50
+ );
51
+ return true;
43
52
  }
44
- res.redirect(
45
- statusCode,
46
- destinationUrl
47
- ? `${destinationUrl.protocol}//${destinationUrl.hostname}${compiledPath}${search}`
48
- : `${compiledPath}${search}`
49
- );
50
- return true;
51
53
  }
52
54
  }
55
+ } catch (err) {
56
+ console.log(`Redirection error on ${req.host}-----`, err);
53
57
  }
54
58
  });
55
59
  }