@akinon/next 1.26.0-rc.7 → 1.26.0-rc.8

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
@@ -1,5 +1,15 @@
1
1
  # @akinon/next
2
2
 
3
+ ## 1.26.0-rc.8
4
+
5
+ ### Minor Changes
6
+
7
+ - f0c23bc: ZERO-2135: add custom not found page
8
+
9
+ ### Patch Changes
10
+
11
+ - @akinon/eslint-plugin-projectzero@1.26.0-rc.8
12
+
3
13
  ## 1.26.0-rc.7
4
14
 
5
15
  ### Patch Changes
@@ -153,6 +153,7 @@ const withPzDefault =
153
153
 
154
154
  req.middlewareParams = {
155
155
  commerceUrl,
156
+ found: true,
156
157
  rewrites: {}
157
158
  };
158
159
 
@@ -186,6 +187,19 @@ const withPzDefault =
186
187
  locale.length ? `${locale}/` : ''
187
188
  }${currency}${prettyUrl ?? pathnameWithoutLocale}`;
188
189
 
190
+ if (
191
+ !req.middlewareParams.found &&
192
+ Settings.customNotFoundEnabled
193
+ ) {
194
+ let pathname = url.pathname
195
+ .replace(/\/+$/, '')
196
+ .split('/');
197
+ url.pathname = url.pathname.replace(
198
+ pathname.pop(),
199
+ 'pz-not-found'
200
+ );
201
+ }
202
+
189
203
  Settings.rewrites.forEach((rewrite) => {
190
204
  url.pathname = url.pathname.replace(
191
205
  rewrite.source,
@@ -26,6 +26,7 @@ export {
26
26
  export interface PzNextRequest extends NextRequest {
27
27
  middlewareParams: {
28
28
  commerceUrl: string;
29
+ found: boolean;
29
30
  rewrites: {
30
31
  locale?: string;
31
32
  prettyUrl?: string;
@@ -98,6 +98,8 @@ const withPrettyUrl =
98
98
  return middleware(req, event);
99
99
  }
100
100
 
101
+ req.middlewareParams.found = false;
102
+
101
103
  return middleware(req, event);
102
104
  };
103
105
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@akinon/next",
3
3
  "description": "Core package for Project Zero Next",
4
- "version": "1.26.0-rc.7",
4
+ "version": "1.26.0-rc.8",
5
5
  "private": false,
6
6
  "license": "MIT",
7
7
  "bin": {
package/types/index.ts CHANGED
@@ -187,6 +187,7 @@ export interface Settings {
187
187
  extraPaymentTypes?: string[];
188
188
  masterpassJsUrl?: string;
189
189
  };
190
+ customNotFoundEnabled: boolean;
190
191
  }
191
192
 
192
193
  export interface CacheOptions {