From e72a5de1d05093119dc13cb019b6304959b6d5a0 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Mon, 1 Jul 2024 17:49:44 +0100 Subject: [PATCH 01/11] chore: import runtime config from '#imports' (#3008) --- specs/fixtures/basic_usage/app.vue | 2 +- src/runtime/routing/extends/router.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/specs/fixtures/basic_usage/app.vue b/specs/fixtures/basic_usage/app.vue index c0937df0c..fcb7faf7f 100644 --- a/specs/fixtures/basic_usage/app.vue +++ b/specs/fixtures/basic_usage/app.vue @@ -1,6 +1,6 @@ <` + + const html = await $fetch(url) + const dom = getDom(html) + + // the localized should be the same as encoded + expect(dom.querySelector('#slp-xss a').href).toEqual(encodeURI('/nl' + url)) + }) }) diff --git a/specs/fixtures/basic_usage/pages/experimental/[...slug].vue b/specs/fixtures/basic_usage/pages/experimental/[...slug].vue new file mode 100644 index 000000000..5c550a091 --- /dev/null +++ b/specs/fixtures/basic_usage/pages/experimental/[...slug].vue @@ -0,0 +1,8 @@ + + + diff --git a/src/runtime/components/SwitchLocalePathLink.ts b/src/runtime/components/SwitchLocalePathLink.ts index 906a04fbd..3166d0cce 100644 --- a/src/runtime/components/SwitchLocalePathLink.ts +++ b/src/runtime/components/SwitchLocalePathLink.ts @@ -21,7 +21,7 @@ export default defineComponent({ return () => [ h(Comment, `${SWITCH_LOCALE_PATH_LINK_IDENTIFIER}-[${props.locale}]`), - h(NuxtLink, { ...attrs, to: switchLocalePath(props.locale) }, slots.default), + h(NuxtLink, { ...attrs, to: encodeURI(switchLocalePath(props.locale)) }, slots.default), h(Comment, `/${SWITCH_LOCALE_PATH_LINK_IDENTIFIER}`) ] } diff --git a/src/runtime/plugins/switch-locale-path-ssr.ts b/src/runtime/plugins/switch-locale-path-ssr.ts index 87d3911d2..598665889 100644 --- a/src/runtime/plugins/switch-locale-path-ssr.ts +++ b/src/runtime/plugins/switch-locale-path-ssr.ts @@ -25,7 +25,8 @@ export default defineNuxtPlugin({ ctx.renderResult.html = ctx.renderResult.html.replaceAll( switchLocalePathLinkWrapperExpr, - (match: string, p1: string) => match.replace(/href="([^"]+)"/, `href="${switchLocalePath(p1 ?? '')}"`) + (match: string, p1: string) => + match.replace(/href="([^"]+)"/, `href="${encodeURI(switchLocalePath(p1 ?? ''))}"`) ) }) } From 6f6a5b023f579189dcf360f774fce4f0ca415382 Mon Sep 17 00:00:00 2001 From: Bobbie Goede Date: Sun, 28 Jul 2024 11:50:39 +0200 Subject: [PATCH 09/11] release: v8.3.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8bd8fa2f4..ca590cce5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@nuxtjs/i18n", "description": "i18n for Nuxt", - "version": "8.3.2", + "version": "8.3.3", "homepage": "https://i18n.nuxtjs.org", "bugs": { "url": "https://github.com/nuxt-community/i18n-module/issues" From 9c9008926ce04662ebad09acb30f38517a34180d Mon Sep 17 00:00:00 2001 From: BobbieGoede Date: Sun, 28 Jul 2024 09:51:23 +0000 Subject: [PATCH 10/11] chore: generate changelog --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f5d4b111..ed979d7cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +# v8.3.3 (2024-07-28T09:51:21Z) + +This changelog is generated by [GitHub Releases](https://github.com/nuxt-modules/i18n/releases/tag/v8.3.3) + +###    🐞 Bug Fixes + +- Encode `switchLocalePath` during SSR replacement  -  by @BobbieGoede in https://github.com/nuxt-modules/i18n/issues/3043 [(28d22)](https://github.com/nuxt-modules/i18n/commit/28d22aa6) + +#####     [View changes on GitHub](https://github.com/nuxt-modules/i18n/compare/v8.3.2...v8.3.3) + # v8.3.2 (2024-07-27T04:42:45Z) This changelog is generated by [GitHub Releases](https://github.com/nuxt-modules/i18n/releases/tag/v8.3.2) From 25a883b8122ba69153d7e2adb86b4b5077de12fd Mon Sep 17 00:00:00 2001 From: Hoyt Date: Wed, 14 Aug 2024 00:53:03 +0800 Subject: [PATCH 11/11] feat: add httpOnly flag to cookie options in getI18nCookie function --- src/constants.ts | 3 ++- src/runtime/internal.ts | 3 ++- src/types.ts | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index ba59587c5..83697b1ab 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -66,7 +66,8 @@ export const DEFAULT_OPTIONS = { cookieSecure: false, fallbackLocale: '', redirectOn: 'root', - useCookie: true + useCookie: true, + httpOnly: false, }, differentDomains: false, baseUrl: '', diff --git a/src/runtime/internal.ts b/src/runtime/internal.ts index c2d8eaa37..83290ba51 100644 --- a/src/runtime/internal.ts +++ b/src/runtime/internal.ts @@ -99,7 +99,8 @@ export function getI18nCookie() { expires: new Date(date.setDate(date.getDate() + 365)), path: '/', sameSite: detect && detect.cookieCrossOrigin ? 'none' : 'lax', - secure: (detect && detect.cookieCrossOrigin) || (detect && detect.cookieSecure) + secure: (detect && detect.cookieCrossOrigin) || (detect && detect.cookieSecure), + httpOnly: detect && detect.httpOnly ? true : false } if (detect && detect.cookieDomain) { diff --git a/src/types.ts b/src/types.ts index d7b479d48..092e6bf63 100644 --- a/src/types.ts +++ b/src/types.ts @@ -14,7 +14,8 @@ export interface DetectBrowserLanguageOptions { cookieSecure?: boolean fallbackLocale?: Locale | null redirectOn?: RedirectOnOptions - useCookie?: boolean + useCookie?: boolean, + httpOnly?: boolean } export type LocaleType = 'static' | 'dynamic' | 'unknown'