@nuxtjs/i18n-edge 10.4.0-29728007.8564ea1 → 10.4.0-29728199.3dc3b07

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/dist/module.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "nuxt": ">=3.0.0-rc.11",
6
6
  "bridge": false
7
7
  },
8
- "version": "10.4.0-29728007.8564ea1",
8
+ "version": "10.4.0-29728199.3dc3b07",
9
9
  "builder": {
10
10
  "@nuxt/module-builder": "1.0.2",
11
11
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -1210,7 +1210,7 @@ const HeistPlugin = (options, ctx, nuxt = useNuxt()) => {
1210
1210
  }));
1211
1211
  };
1212
1212
 
1213
- const version = "10.4.0-29728007.8564ea1";
1213
+ const version = "10.4.0-29728199.3dc3b07";
1214
1214
 
1215
1215
  async function extendBundler(ctx, nuxt) {
1216
1216
  const pluginOptions = {
@@ -1,20 +1,12 @@
1
1
  import { useNuxtI18nContext, useResolvedLocale } from "../context.js";
2
2
  import { detectLocale, loadAndSetLocale, navigate } from "../utils.js";
3
- import { addRouteMiddleware, defineNuxtPlugin, defineNuxtRouteMiddleware, useNuxtApp, useRouter } from "#imports";
3
+ import { addRouteMiddleware, defineNuxtPlugin, defineNuxtRouteMiddleware, useNuxtApp } from "#imports";
4
4
  export default defineNuxtPlugin({
5
5
  name: "i18n:plugin:route-locale-detect",
6
6
  dependsOn: !__I18N_PRELOAD__ ? ["i18n:plugin"] : ["i18n:plugin", "i18n:plugin:preload"],
7
7
  async setup(_nuxt) {
8
8
  const nuxt = useNuxtApp(_nuxt._id);
9
9
  const ctx = useNuxtI18nContext(nuxt);
10
- if (__I18N_COMPACT_ROUTES__) {
11
- const router = useRouter();
12
- for (const route of router.getRoutes()) {
13
- if (route.meta?.__i18nCompact && route.meta.key == null) {
14
- route.meta.key = (r) => r.path;
15
- }
16
- }
17
- }
18
10
  const resolvedLocale = useResolvedLocale();
19
11
  await nuxt.runWithContext(
20
12
  () => loadAndSetLocale(
@@ -1,12 +1,12 @@
1
1
  import { stringify } from "devalue";
2
2
  import { defineI18nMiddleware } from "@intlify/h3";
3
- import { defineNitroPlugin, useStorage } from "nitropack/runtime";
3
+ import { defineNitroPlugin, useRuntimeConfig, useStorage } from "nitropack/runtime";
4
4
  import { initializeI18nContext, tryUseI18nContext, useI18nContext } from "./context.js";
5
5
  import { createUserLocaleDetector } from "./utils/locale-detector.js";
6
6
  import { pickNested } from "./utils/messages-utils.js";
7
7
  import { isSupportedLocale } from "../shared/locales.js";
8
8
  import { setupVueI18nOptions } from "../shared/vue-i18n.js";
9
- import { joinURL } from "ufo";
9
+ import { joinURL, parsePath } from "ufo";
10
10
  import { appId } from "#internal/nuxt.config.mjs";
11
11
  import { localeDetector } from "#internal/i18n-locale-detector.mjs";
12
12
  import { resolveRootRedirect, useI18nDetection, useRuntimeI18n } from "../shared/utils.js";
@@ -91,8 +91,8 @@ export default defineNitroPlugin(async (nitro) => {
91
91
  }
92
92
  let resolvedPath = void 0;
93
93
  let redirectCode = 302;
94
- const requestURL = getRequestURL(event);
95
- if (rootRedirect && requestURL.pathname === "/") {
94
+ const pathname = parsePath(event.path).pathname;
95
+ if (rootRedirect && pathname === "/") {
96
96
  locale = detection.enabled && locale || defaultLocale;
97
97
  resolvedPath = isSupportedLocale(detector.route(rootRedirect.path)) && rootRedirect.path || matchLocalized(rootRedirect.path, locale, defaultLocale);
98
98
  redirectCode = rootRedirect.code;
@@ -101,7 +101,7 @@ export default defineNitroPlugin(async (nitro) => {
101
101
  }
102
102
  switch (detection.redirectOn) {
103
103
  case "root":
104
- if (requestURL.pathname !== "/") {
104
+ if (pathname !== "/") {
105
105
  break;
106
106
  }
107
107
  // fallthrough (root has no prefix)
@@ -114,7 +114,7 @@ export default defineNitroPlugin(async (nitro) => {
114
114
  resolvedPath ??= getLocalizedMatch(locale);
115
115
  break;
116
116
  }
117
- if (requestURL.pathname === "/" && __I18N_STRATEGY__ === "prefix") {
117
+ if (pathname === "/" && __I18N_STRATEGY__ === "prefix") {
118
118
  resolvedPath ??= getLocalizedMatch(defaultLocale);
119
119
  }
120
120
  return { path: resolvedPath, code: redirectCode, locale };
@@ -133,17 +133,23 @@ export default defineNitroPlugin(async (nitro) => {
133
133
  const detector = useDetectors(event, detection);
134
134
  const localeSegment = detector.route(event.path);
135
135
  const pathLocale = isSupportedLocale(localeSegment) && localeSegment || void 0;
136
- const path = (pathLocale && url.pathname.slice(pathLocale.length + 1)) ?? url.pathname;
136
+ const { pathname } = parsePath(event.path);
137
+ const path = (pathLocale && pathname.slice(pathLocale.length + 1)) ?? pathname;
137
138
  if (!url.pathname.includes(__I18N_SERVER_ROUTE__) && !isExistingNuxtRoute(path)) {
138
139
  return;
139
140
  }
140
141
  const resolved = resolveRedirectPath(event, path, pathLocale, ctx.vueI18nOptions.defaultLocale, detector);
141
- if (resolved.path && resolved.path !== url.pathname) {
142
+ if (resolved.path && resolved.path !== pathname) {
142
143
  ctx.detectLocale = resolved.locale;
143
144
  detection.useCookie && setCookie(event, detection.cookieKey, resolved.locale, cookieOptions);
144
145
  context.response = createRedirectResponse(
145
146
  event,
146
- joinURL(baseUrlGetter(event, ctx.vueI18nOptions.defaultLocale), resolved.path + url.search),
147
+ // the resolved path is base-free (matched against base-free routes), re-add `app.baseURL`
148
+ joinURL(
149
+ baseUrlGetter(event, ctx.vueI18nOptions.defaultLocale),
150
+ useRuntimeConfig(event).app.baseURL,
151
+ resolved.path + url.search
152
+ ),
147
153
  resolved.code
148
154
  );
149
155
  return;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nuxtjs/i18n-edge",
3
3
  "type": "module",
4
- "version": "10.4.0-29728007.8564ea1",
4
+ "version": "10.4.0-29728199.3dc3b07",
5
5
  "description": "Internationalization for Nuxt",
6
6
  "contributors": [
7
7
  {