@akinon/next 1.48.0-rc.2 → 1.48.0-rc.4

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,69 @@
1
1
  # @akinon/next
2
2
 
3
+ ## 1.48.0-rc.4
4
+
5
+ ### Minor Changes
6
+
7
+ - 5dfeea0: ZERO-2801: Revert ZERO-2801
8
+
9
+ ## 1.48.0-rc.3
10
+
11
+ ### Minor Changes
12
+
13
+ - 90282b53: ZERO-2729: Audit packages for yarn and npm and also update app-template
14
+ - 572d2e84: ZERO-2667: Add iframe support for redirection payment methods
15
+ - a4c8d6a9: 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
+ - c53ea3e6: ZERO-2609: Reset additional form fields when selectedFormType is not company
19
+ - d93a507: ZERO-2900: Fix pretty url rewrite
20
+ - 8d9ac9a: ZERO-2794: Add field to order type
21
+ - 70279e7: ZERO-2817: Add metrics endpoint in default middleware
22
+ - 6c25f66: ZERO-2551: Check CACHE_HOST variable
23
+ - bc2b411: ZERO-2825: Add attribute-based shipping options to checkout page
24
+ - 3bf2dd9: ZERO-2551: Fix search page
25
+ - e9541a1: ZERO-2816: Add headers to url
26
+ - c53ef7b9: 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.
27
+ - 9d94f7e: ZERO-2820: update parent pk usage for menu generator
28
+ - 2e6104d: ZERO-2888:Edit the numbering in the pagination and the visibility of the prev and next buttons
29
+ - 64699d3: ZERO-2761: Fix invalid import for plugin module
30
+ - 0d3a913e: ZERO-2725: Update decimal scale in Price component
31
+ - 1448a96e: ZERO-2612: add errors type in CheckoutState
32
+ - 1ec2e9d: ZERO-2895: Update app-fetch to include cookies in headers
33
+ - d6edb1d: ZERO-2551: Fix searchparams handling for list and other routes
34
+ - d3474c64: ZERO-2655: Add data source shipping option
35
+ - 75080fd6: ZERO-2630: Add max limit to postcode area
36
+ - 17f8752: ZERO-2816: Make the incoming currency lowercase
37
+ - c45b62c: ZERO-2818: Add upload and download support for b2b package
38
+ - 91265bba: ZERO-2551: Improve pretty url and caching performance
39
+ - bbe18b9f: ZERO-2575: Fix build error
40
+ - d409996: ZERO-2781: Refactor buildClientRequestUrl function to support caching and options
41
+ - 4920742: Disable getCachedTranslations
42
+ - 12a873e: ZERO-2846:Edit the siteKey regex in the response from GetCaptcha
43
+ - 7e56d6b: ZERO-2841: Update api tagTypes
44
+ - 94b6928: ZERO-2551: Add cache handler check in url-redirection middleware
45
+ - 98bb8dcd: ZERO-2706: Cache getTranlations method
46
+ - 46b7aad: ZERO-2775: Add condition and logger for menuitemmodel data
47
+ - dcc8a150: ZERO-2694: added build step to RC branch pipeline
48
+ - 8f47cca: ZERO-2829: fix and add nested JSON support for useFormData in api/client route
49
+ - fad27689: ZERO-2739: add gpay to payment plugin map
50
+ - dff0d595: ZERO-2659: add formData support to proxy api requests
51
+ - fdd0b41: ZERO-2706: Add optimized translation support
52
+ - eecb282: ZERO-2607: Update address-related functions to include invalidateTag option
53
+ - f2c325c: ZERO-2838: Move file input component into @akinon/next
54
+ - 9e25a64: ZERO-2835: Update category page layout with breadcrumb
55
+ - beb499e6: ZERO-2551: Add new tsconfig paths
56
+ - 146ea39: ZERO-2774: Update imports
57
+ - f2c92d5: ZERO-2816: Update cookie name
58
+ - 7bd3d99: ZERO-2801: Refactor locale middleware to handle single locale configuration
59
+ - c47be30d: ZERO-2744: Update Order and OrderItem types
60
+ - e9a46acb: ZERO-2738: add CVC input to registered cards in Masterpass
61
+ - f046f8e0: ZERO-2575: update version for react-number-format
62
+ - b9273fd: ZERO-2889: add host headers to requests
63
+ - 86d25315: ZERO-2693: resolve dependency collision warning for eslint-config-next
64
+ - c670bd4: ZERO-2900: Add middleware rewrite functionality
65
+ - 3f9b8d7: ZERO-2761: Update plugins.js for akinon-next
66
+
3
67
  ## 1.48.0-rc.2
4
68
 
5
69
  ### Minor Changes
@@ -5,6 +5,22 @@ 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
+
8
24
  const withLocale =
9
25
  (middleware: NextMiddleware) =>
10
26
  async (req: PzNextRequest, event: NextFetchEvent) => {
@@ -12,12 +28,12 @@ const withLocale =
12
28
 
13
29
  try {
14
30
  const url = req.nextUrl.clone();
15
- const {
16
- locales,
17
- localeUrlStrategy,
18
- defaultLocaleValue,
19
- redirectToDefaultLocale
20
- } = settings.localization;
31
+ const matchedLocale = getMatchedLocale(url.pathname);
32
+ let { localeUrlStrategy, defaultLocaleValue, redirectToDefaultLocale } =
33
+ settings.localization;
34
+
35
+ localeUrlStrategy =
36
+ localeUrlStrategy ?? LocaleUrlStrategy.HideDefaultLocale;
21
37
 
22
38
  if (!defaultLocaleValue) {
23
39
  logger.error('Default locale value is not defined in settings.', {
@@ -29,34 +45,16 @@ const withLocale =
29
45
  }
30
46
 
31
47
  if (
32
- locales.length === 1 &&
33
- localeUrlStrategy === LocaleUrlStrategy.ShowAllLocales
48
+ !matchedLocale?.length &&
49
+ localeUrlStrategy === LocaleUrlStrategy.ShowAllLocales &&
50
+ redirectToDefaultLocale &&
51
+ req.method === 'GET'
34
52
  ) {
35
- const singleLocale = locales[0].value;
36
- const pathParts = url.pathname.split('/').filter(Boolean);
37
-
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;
53
+ url.pathname = `/${defaultLocaleValue}${url.pathname}`;
54
+ return NextResponse.redirect(url);
59
55
  }
56
+
57
+ req.middlewareParams.rewrites.locale = matchedLocale;
60
58
  } catch (error) {
61
59
  logger.error('withLocale error', {
62
60
  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.48.0-rc.2",
4
+ "version": "1.48.0-rc.4",
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.48.0-rc.2",
33
+ "@akinon/eslint-plugin-projectzero": "1.48.0-rc.4",
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",