@akinon/next 1.43.0-rc.5 → 1.43.0-rc.7

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,50 @@
1
1
  # @akinon/next
2
2
 
3
+ ## 1.43.0-rc.7
4
+
5
+ ### Minor Changes
6
+
7
+ - 7bd3d99: ZERO-2801: Refactor locale middleware to handle single locale configuration
8
+
9
+ ## 1.43.0-rc.6
10
+
11
+ ### Minor Changes
12
+
13
+ - 90282b5: ZERO-2729: Audit packages for yarn and npm and also update app-template
14
+ - 572d2e8: ZERO-2667: Add iframe support for redirection payment methods
15
+ - a4c8d6a: ZERO-2663: Fix the image url for gif and svgs and return them without options
16
+ - fda5b92: ZERO-2725: fix invalid import
17
+ - 2d9b2b2: ZERO-2816: Add segment to headers
18
+ - c53ea3e: ZERO-2609: Reset additional form fields when selectedFormType is not company
19
+ - 8d9ac9a: ZERO-2794: Add field to order type
20
+ - e9541a1: ZERO-2816: Add headers to url
21
+ - c53ef7b: ZERO-2668: The Link component has been updated to improve the logic for handling href values. Previously, if the href was not a string or started with 'http', it would return the href as is. Now, if the href is not provided, it will default to '#' to prevent any potential errors. Additionally, if the href is a string and does not start with 'http', it will be formatted with the locale and pathname, based on the localeUrlStrategy and defaultLocaleValue. This ensures that the correct href is generated based on the localization settings.
22
+ - 64699d3: ZERO-2761: Fix invalid import for plugin module
23
+ - 0d3a913: ZERO-2725: Update decimal scale in Price component
24
+ - 1448a96: ZERO-2612: add errors type in CheckoutState
25
+ - d3474c6: ZERO-2655: Add data source shipping option
26
+ - 75080fd: ZERO-2630: Add max limit to postcode area
27
+ - 17f8752: ZERO-2816: Make the incoming currency lowercase
28
+ - 91265bb: ZERO-2551: Improve pretty url and caching performance
29
+ - bbe18b9: ZERO-2575: Fix build error
30
+ - d409996: ZERO-2781: Refactor buildClientRequestUrl function to support caching and options
31
+ - 94b6928: ZERO-2551: Add cache handler check in url-redirection middleware
32
+ - 98bb8dc: ZERO-2706: Cache getTranlations method
33
+ - 46b7aad: ZERO-2775: Add condition and logger for menuitemmodel data
34
+ - dcc8a15: ZERO-2694: added build step to RC branch pipeline
35
+ - fad2768: ZERO-2739: add gpay to payment plugin map
36
+ - dff0d59: ZERO-2659: add formData support to proxy api requests
37
+ - eecb282: ZERO-2607: Update address-related functions to include invalidateTag option
38
+ - 4a163f2: ZERO-2761: Add condition for basket summary
39
+ - beb499e: ZERO-2551: Add new tsconfig paths
40
+ - 146ea39: ZERO-2774: Update imports
41
+ - f2c92d5: ZERO-2816: Update cookie name
42
+ - c47be30: ZERO-2744: Update Order and OrderItem types
43
+ - e9a46ac: ZERO-2738: add CVC input to registered cards in Masterpass
44
+ - f046f8e: ZERO-2575: update version for react-number-format
45
+ - 86d2531: ZERO-2693: resolve dependency collision warning for eslint-config-next
46
+ - 3f9b8d7: ZERO-2761: Update plugins.js for akinon-next
47
+
3
48
  ## 1.43.0-rc.5
4
49
 
5
50
  ### Minor Changes
@@ -5,22 +5,6 @@ import { LocaleUrlStrategy } from '../localization';
5
5
  import { urlLocaleMatcherRegex } from '../utils';
6
6
  import logger from '../utils/log';
7
7
 
8
- const getMatchedLocale = (pathname: string) => {
9
- let matchedLocale = pathname.match(urlLocaleMatcherRegex)?.[0] ?? '';
10
- matchedLocale = matchedLocale.replace('/', '');
11
-
12
- if (!matchedLocale.length) {
13
- if (
14
- settings.localization.localeUrlStrategy !==
15
- LocaleUrlStrategy.ShowAllLocales
16
- ) {
17
- matchedLocale = settings.localization.defaultLocaleValue;
18
- }
19
- }
20
-
21
- return matchedLocale;
22
- };
23
-
24
8
  const withLocale =
25
9
  (middleware: NextMiddleware) =>
26
10
  async (req: PzNextRequest, event: NextFetchEvent) => {
@@ -28,12 +12,12 @@ const withLocale =
28
12
 
29
13
  try {
30
14
  const url = req.nextUrl.clone();
31
- const matchedLocale = getMatchedLocale(url.pathname);
32
- let { localeUrlStrategy, defaultLocaleValue, redirectToDefaultLocale } =
33
- settings.localization;
34
-
35
- localeUrlStrategy =
36
- localeUrlStrategy ?? LocaleUrlStrategy.HideDefaultLocale;
15
+ const {
16
+ locales,
17
+ localeUrlStrategy,
18
+ defaultLocaleValue,
19
+ redirectToDefaultLocale
20
+ } = settings.localization;
37
21
 
38
22
  if (!defaultLocaleValue) {
39
23
  logger.error('Default locale value is not defined in settings.', {
@@ -45,16 +29,34 @@ const withLocale =
45
29
  }
46
30
 
47
31
  if (
48
- !matchedLocale?.length &&
49
- localeUrlStrategy === LocaleUrlStrategy.ShowAllLocales &&
50
- redirectToDefaultLocale &&
51
- req.method === 'GET'
32
+ locales.length === 1 &&
33
+ localeUrlStrategy === LocaleUrlStrategy.ShowAllLocales
52
34
  ) {
53
- url.pathname = `/${defaultLocaleValue}${url.pathname}`;
54
- return NextResponse.redirect(url);
55
- }
35
+ const singleLocale = locales[0].value;
36
+ const pathParts = url.pathname.split('/').filter(Boolean);
56
37
 
57
- req.middlewareParams.rewrites.locale = matchedLocale;
38
+ if (pathParts[0] === singleLocale) {
39
+ url.pathname = '/' + pathParts.slice(1).join('/');
40
+ return NextResponse.redirect(url);
41
+ }
42
+
43
+ req.middlewareParams.rewrites.locale = singleLocale;
44
+ } else {
45
+ const matchedLocale =
46
+ url.pathname.match(urlLocaleMatcherRegex)?.[0]?.replace('/', '') ||
47
+ '';
48
+ if (
49
+ !matchedLocale &&
50
+ localeUrlStrategy === LocaleUrlStrategy.ShowAllLocales &&
51
+ redirectToDefaultLocale &&
52
+ req.method === 'GET'
53
+ ) {
54
+ url.pathname = `/${defaultLocaleValue}${url.pathname}`;
55
+ return NextResponse.redirect(url);
56
+ }
57
+ req.middlewareParams.rewrites.locale =
58
+ matchedLocale || defaultLocaleValue;
59
+ }
58
60
  } catch (error) {
59
61
  logger.error('withLocale error', {
60
62
  error,
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.43.0-rc.5",
4
+ "version": "1.43.0-rc.7",
5
5
  "private": false,
6
6
  "license": "MIT",
7
7
  "bin": {
@@ -30,7 +30,7 @@
30
30
  "set-cookie-parser": "2.6.0"
31
31
  },
32
32
  "devDependencies": {
33
- "@akinon/eslint-plugin-projectzero": "1.43.0-rc.5",
33
+ "@akinon/eslint-plugin-projectzero": "1.43.0-rc.7",
34
34
  "@types/react-redux": "7.1.30",
35
35
  "@types/set-cookie-parser": "2.4.7",
36
36
  "@typescript-eslint/eslint-plugin": "6.7.4",