@akinon/next 1.28.0-rc.0 → 1.29.0-rc.2

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,16 @@
1
1
  # @akinon/next
2
2
 
3
+ ## 1.29.0-rc.2
4
+
5
+ ### Minor Changes
6
+
7
+ - a7e432f: ZERO-2534: Fix for recapthca regex for replacing the special chars.
8
+ - 495d155: ZERO-2505: findBaseDir function is united and move on to the utils
9
+ - 495d155: ZERO-2524: Zero-cli dist checks for changes and renders it to the terminal.
10
+ - f76f079: ZERO-2493: Add redirect util function
11
+
12
+ ## 1.28.0-rc.1
13
+
3
14
  ## 1.28.0-rc.0
4
15
 
5
16
  ### Minor Changes
@@ -22,9 +22,9 @@ const userApi = api.injectEndpoints({
22
22
  getCaptcha: build.query<GetCaptchaResponse, void>({
23
23
  query: () => buildClientRequestUrl(user.captcha),
24
24
  transformResponse: (response: { html: string }) => {
25
- const siteKeyMatch = response.html.match(/sitekey=["|']\w+/gi);
25
+ const siteKeyMatch = response.html.match(/sitekey=["|'][^"']+/gi);
26
26
  const csrfTokenMatch = response.html.match(
27
- /name=['|"]csrfmiddlewaretoken['|"] value=['|"]\w+/gi
27
+ /name=['|"]csrfmiddlewaretoken['|"] value=['|"][^'"]+/gi
28
28
  );
29
29
  const siteKey = siteKeyMatch?.[0].replace(/sitekey=["|']/, '') || '';
30
30
  const csrfToken =
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.28.0-rc.0",
4
+ "version": "1.29.0-rc.2",
5
5
  "private": false,
6
6
  "license": "MIT",
7
7
  "bin": {
@@ -32,7 +32,7 @@
32
32
  "@typescript-eslint/eslint-plugin": "6.7.4",
33
33
  "@typescript-eslint/parser": "6.7.4",
34
34
  "eslint": "^8.14.0",
35
- "@akinon/eslint-plugin-projectzero": "1.24.0",
35
+ "@akinon/eslint-plugin-projectzero": "1.29.0-rc.2",
36
36
  "eslint-config-prettier": "8.5.0"
37
37
  }
38
38
  }
@@ -0,0 +1,30 @@
1
+ import { redirect as nextRedirect, RedirectType } from 'next/navigation';
2
+ import Settings from 'settings';
3
+ import { headers } from 'next/headers';
4
+ import { ServerVariables } from '@akinon/next/utils/server-variables';
5
+ import { getUrlPathWithLocale } from '@akinon/next/utils/localization';
6
+
7
+ export const redirect = (path: string, type?: RedirectType) => {
8
+ const nextHeaders = headers();
9
+ const pageUrl = new URL(
10
+ nextHeaders.get('pz-url') ?? process.env.NEXT_PUBLIC_URL
11
+ );
12
+
13
+ const currentLocale = Settings.localization.locales.find(
14
+ (locale) => locale.value === ServerVariables.locale
15
+ );
16
+
17
+ const callbackUrl = pageUrl.pathname;
18
+ const redirectUrlWithLocale = getUrlPathWithLocale(
19
+ path,
20
+ currentLocale.localePath ?? currentLocale.value
21
+ );
22
+
23
+ const redirectUrl = `${redirectUrlWithLocale}?callbackUrl=${callbackUrl}`;
24
+
25
+ if (type) {
26
+ return nextRedirect(redirectUrl, type);
27
+ } else {
28
+ return nextRedirect(redirectUrl);
29
+ }
30
+ };