nuxt-typed-router 3.2.0 → 3.2.1-beta.0

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,5 +5,5 @@
5
5
  "nuxt": "^3.0.0",
6
6
  "bridge": false
7
7
  },
8
- "version": "3.2.0"
8
+ "version": "3.2.1-beta.0"
9
9
  }
package/dist/module.mjs CHANGED
@@ -1399,24 +1399,8 @@ const specialCharacterRegxp = /([^a-zA-Z0-9_])/gm;
1399
1399
  function is18Sibling(source, route) {
1400
1400
  const { i18n, i18nOptions, i18nLocales } = moduleOptionStore;
1401
1401
  if (i18n && i18nOptions && i18nOptions?.strategy !== "no_prefix") {
1402
- const separator = i18nOptions?.routesNameSeparator ?? "___";
1403
1402
  const i18LocalesRecognizer = i18nLocales?.map((m) => m.replace(specialCharacterRegxp, "\\$&")).join("|");
1404
- return source.some((rt) => {
1405
- return route.name?.match(
1406
- new RegExp(
1407
- `^(${rt.name?.replace(
1408
- specialCharacterRegxp,
1409
- "\\$&"
1410
- )})${separator}(${i18LocalesRecognizer})`,
1411
- "g"
1412
- )
1413
- ) || route.path?.match(
1414
- new RegExp(
1415
- `/?(${i18LocalesRecognizer})${rt.path.replace(specialCharacterRegxp, "\\$&")}${rt.path === "/" ? "?" : ""}`,
1416
- "g"
1417
- )
1418
- );
1419
- });
1403
+ return !!route.path?.match(new RegExp(`/?(${i18LocalesRecognizer})(/.+)?`, "g"));
1420
1404
  }
1421
1405
  return false;
1422
1406
  }
@@ -1434,6 +1418,10 @@ function modifyRoutePrefixDefaultIfI18n(route) {
1434
1418
  if (match) {
1435
1419
  const [_, routeName] = match;
1436
1420
  route.name = routeName;
1421
+ return {
1422
+ ...route,
1423
+ name: routeName
1424
+ };
1437
1425
  }
1438
1426
  } else if (i18nOptions?.strategy === "prefix_except_default") {
1439
1427
  let defaultLocale = i18nLocales.find((f) => f === i18nOptions.defaultLocale) ? i18nOptions.defaultLocale?.replace(specialCharacterRegxp, "\\$&") : "";
@@ -1441,10 +1429,14 @@ function modifyRoutePrefixDefaultIfI18n(route) {
1441
1429
  const match = routeDefaultNameRegXp.exec(route.name);
1442
1430
  if (match) {
1443
1431
  const [_, routeName] = match;
1444
- route.name = routeName;
1432
+ return {
1433
+ ...route,
1434
+ name: routeName
1435
+ };
1445
1436
  }
1446
1437
  }
1447
1438
  }
1439
+ return route;
1448
1440
  }
1449
1441
 
1450
1442
  function createKeyedName(route, parent) {
@@ -1467,7 +1459,7 @@ function createNameKeyFromFullName(route, level, parentName) {
1467
1459
  return keyName;
1468
1460
  }
1469
1461
  function walkThoughRoutes({
1470
- route,
1462
+ route: _route,
1471
1463
  level,
1472
1464
  siblings,
1473
1465
  parent,
@@ -1476,9 +1468,9 @@ function walkThoughRoutes({
1476
1468
  isLast,
1477
1469
  isLocale
1478
1470
  }) {
1479
- modifyRoutePrefixDefaultIfI18n(route);
1480
- const newPath = `${parent?.path ?? ""}${route.path.startsWith("/") ? route.path : `/${route.path}`}`;
1471
+ const route = modifyRoutePrefixDefaultIfI18n(_route);
1481
1472
  const isLocaleRoute = isLocale || is18Sibling(output.routesPaths, route);
1473
+ const newPath = `${parent?.path ?? ""}${route.path.startsWith("/") ? route.path : `/${route.path}`}`;
1482
1474
  output.routesPaths.push({
1483
1475
  name: route.name,
1484
1476
  path: newPath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-typed-router",
3
- "version": "3.2.0",
3
+ "version": "3.2.1-beta.0",
4
4
  "description": "Provide autocompletion for routes paths, names and params in Nuxt apps",
5
5
  "type": "module",
6
6
  "main": "./dist/module.cjs",