@akinon/next 1.92.0-rc.28 → 1.92.0-rc.30
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 +12 -0
- package/data/server/category.ts +4 -4
- package/hooks/use-localization.ts +2 -3
- package/middlewares/default.ts +32 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @akinon/next
|
|
2
2
|
|
|
3
|
+
## 1.92.0-rc.30
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- a420947d: ZERO-3517: Fix optional chaining for rawData in error logging for category data handlers
|
|
8
|
+
|
|
9
|
+
## 1.92.0-rc.29
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- e1aa030d: ZERO-3473: Refactor locale handling to prioritize cookie value for matched locale
|
|
14
|
+
|
|
3
15
|
## 1.92.0-rc.28
|
|
4
16
|
|
|
5
17
|
## 1.92.0-rc.27
|
package/data/server/category.ts
CHANGED
|
@@ -48,8 +48,8 @@ function getCategoryDataHandler(
|
|
|
48
48
|
logger.fatal('Error while parsing category data', {
|
|
49
49
|
handler: 'getCategoryDataHandler',
|
|
50
50
|
error,
|
|
51
|
-
rawData: rawData
|
|
52
|
-
? `${rawData
|
|
51
|
+
rawData: rawData?.startsWith?.('<!DOCTYPE html>')
|
|
52
|
+
? `${rawData?.substring(0, 50)}...`
|
|
53
53
|
: rawData
|
|
54
54
|
});
|
|
55
55
|
}
|
|
@@ -138,8 +138,8 @@ function getCategoryBySlugDataHandler(
|
|
|
138
138
|
logger.fatal('Error while parsing category data', {
|
|
139
139
|
handler: 'getCategoryBySlugDataHandler',
|
|
140
140
|
error,
|
|
141
|
-
rawData: rawData
|
|
142
|
-
? `${rawData
|
|
141
|
+
rawData: rawData?.startsWith?.('<!DOCTYPE html>')
|
|
142
|
+
? `${rawData?.substring(0, 50)}...`
|
|
143
143
|
: rawData
|
|
144
144
|
});
|
|
145
145
|
}
|
|
@@ -4,7 +4,6 @@ import { LocalizationContext } from '../localization/provider';
|
|
|
4
4
|
import { useContext } from 'react';
|
|
5
5
|
import { setCookie, urlLocaleMatcherRegex } from '../utils';
|
|
6
6
|
import { LocaleUrlStrategy } from '../localization';
|
|
7
|
-
import { useRouter } from 'next/navigation';
|
|
8
7
|
|
|
9
8
|
export const useLocalization = () => {
|
|
10
9
|
const {
|
|
@@ -18,8 +17,6 @@ export const useLocalization = () => {
|
|
|
18
17
|
localeUrlStrategy
|
|
19
18
|
} = useContext(LocalizationContext);
|
|
20
19
|
|
|
21
|
-
const router = useRouter();
|
|
22
|
-
|
|
23
20
|
/**
|
|
24
21
|
* Sets the locale in the URL.
|
|
25
22
|
* @param locale Locale value defined in the settings.
|
|
@@ -30,6 +27,8 @@ export const useLocalization = () => {
|
|
|
30
27
|
|
|
31
28
|
let targetUrl;
|
|
32
29
|
|
|
30
|
+
setCookie('pz-locale', locale);
|
|
31
|
+
|
|
33
32
|
if (localeUrlStrategy === LocaleUrlStrategy.Subdomain) {
|
|
34
33
|
const hostParts = hostname.split('.');
|
|
35
34
|
const subDomain = hostParts[0];
|
package/middlewares/default.ts
CHANGED
|
@@ -401,6 +401,38 @@ const withPzDefault =
|
|
|
401
401
|
}
|
|
402
402
|
);
|
|
403
403
|
|
|
404
|
+
if (
|
|
405
|
+
!url.pathname.startsWith(
|
|
406
|
+
`/${currency}/orders`
|
|
407
|
+
)
|
|
408
|
+
) {
|
|
409
|
+
const currentCookieLocale =
|
|
410
|
+
req.cookies.get('pz-locale')?.value;
|
|
411
|
+
|
|
412
|
+
const urlHasExplicitLocale =
|
|
413
|
+
url.pathname.match(urlLocaleMatcherRegex);
|
|
414
|
+
const shouldUpdateCookie =
|
|
415
|
+
!currentCookieLocale ||
|
|
416
|
+
urlHasExplicitLocale;
|
|
417
|
+
|
|
418
|
+
if (shouldUpdateCookie) {
|
|
419
|
+
middlewareResult.cookies.set(
|
|
420
|
+
'pz-locale',
|
|
421
|
+
locale?.length > 0
|
|
422
|
+
? locale
|
|
423
|
+
: defaultLocaleValue,
|
|
424
|
+
{
|
|
425
|
+
domain: rootHostname,
|
|
426
|
+
sameSite: 'none',
|
|
427
|
+
secure: true,
|
|
428
|
+
expires: new Date(
|
|
429
|
+
Date.now() + 1000 * 60 * 60 * 24 * 7
|
|
430
|
+
) // 7 days
|
|
431
|
+
}
|
|
432
|
+
);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
404
436
|
if (
|
|
405
437
|
req.cookies.get('pz-locale') &&
|
|
406
438
|
req.cookies.get('pz-locale').value !== locale
|
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.92.0-rc.
|
|
4
|
+
"version": "1.92.0-rc.30",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bin": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"set-cookie-parser": "2.6.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@akinon/eslint-plugin-projectzero": "1.92.0-rc.
|
|
37
|
+
"@akinon/eslint-plugin-projectzero": "1.92.0-rc.30",
|
|
38
38
|
"@babel/core": "7.26.10",
|
|
39
39
|
"@babel/preset-env": "7.26.9",
|
|
40
40
|
"@babel/preset-typescript": "7.27.0",
|