@akinon/next 1.91.0-rc.5 → 1.91.0-rc.6

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,11 @@
1
1
  # @akinon/next
2
2
 
3
+ ## 1.91.0-rc.6
4
+
5
+ ### Minor Changes
6
+
7
+ - 28c7ea7: ZERO-3427: Refactor redirect utility to handle undefined URL and improve locale handling
8
+
3
9
  ## 1.91.0-rc.5
4
10
 
5
11
  ### Minor Changes
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.91.0-rc.5",
4
+ "version": "1.91.0-rc.6",
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.91.0-rc.5",
37
+ "@akinon/eslint-plugin-projectzero": "1.91.0-rc.6",
38
38
  "@babel/core": "7.26.10",
39
39
  "@babel/preset-env": "7.26.9",
40
40
  "@babel/preset-typescript": "7.27.0",
package/utils/redirect.ts CHANGED
@@ -3,21 +3,23 @@ import Settings from 'settings';
3
3
  import { headers } from 'next/headers';
4
4
  import { ServerVariables } from '@akinon/next/utils/server-variables';
5
5
  import { getUrlPathWithLocale } from '@akinon/next/utils/localization';
6
+ import { urlLocaleMatcherRegex } from '@akinon/next/utils';
6
7
 
7
8
  export const redirect = (path: string, type?: RedirectType) => {
8
9
  const nextHeaders = headers();
9
10
  const pageUrl = new URL(
10
- nextHeaders.get('pz-url') ?? process.env.NEXT_PUBLIC_URL
11
+ nextHeaders.get('pz-url') ?? process.env.NEXT_PUBLIC_URL ?? ''
11
12
  );
12
13
 
13
14
  const currentLocale = Settings.localization.locales.find(
14
15
  (locale) => locale.value === ServerVariables.locale
15
16
  );
16
17
 
17
- const callbackUrl = pageUrl.pathname;
18
+ const callbackUrl = pageUrl.pathname.replace(urlLocaleMatcherRegex, '');
19
+
18
20
  const redirectUrlWithLocale = getUrlPathWithLocale(
19
21
  path,
20
- currentLocale.localePath ?? currentLocale.value
22
+ currentLocale?.value
21
23
  );
22
24
 
23
25
  const redirectUrl = `${redirectUrlWithLocale}?callbackUrl=${callbackUrl}`;