@bleedingdev/modern-js-plugin-i18n 3.2.0-ultramodern.24 → 3.2.0-ultramodern.25
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/cjs/server/index.js
CHANGED
|
@@ -243,12 +243,8 @@ const i18nServerPlugin = (options)=>({
|
|
|
243
243
|
}
|
|
244
244
|
const localisedUrlsConfig = (0, localisedUrls_js_namespaceObject.resolveLocalisedUrlsConfig)(localisedUrls);
|
|
245
245
|
if (localisedUrlsConfig.enabled) {
|
|
246
|
-
const
|
|
247
|
-
|
|
248
|
-
const pathWithoutLanguage = remainingPath.split('/').filter(Boolean).slice(1).join('/');
|
|
249
|
-
const canonicalLocalizedPath = (0, localisedUrls_js_namespaceObject.resolveLocalisedPath)(`/${pathWithoutLanguage}`, language, languages, localisedUrlsConfig.map);
|
|
250
|
-
const expectedPathname = '/' === basePath ? `/${language}${'/' === canonicalLocalizedPath ? '' : canonicalLocalizedPath}` : `${basePath}/${language}${'/' === canonicalLocalizedPath ? '' : canonicalLocalizedPath}`;
|
|
251
|
-
if (expectedPathname !== pathname) return c.redirect(`${expectedPathname}${url.search}${url.hash}`);
|
|
246
|
+
const expectedUrl = buildLocalizedUrl(c.req, originUrlPath, language, languages, localisedUrls);
|
|
247
|
+
if (expectedUrl !== `${pathname}${url.search}${url.hash}`) return c.redirect(expectedUrl);
|
|
252
248
|
}
|
|
253
249
|
await next();
|
|
254
250
|
}
|
|
@@ -212,12 +212,8 @@ const i18nServerPlugin = (options)=>({
|
|
|
212
212
|
}
|
|
213
213
|
const localisedUrlsConfig = resolveLocalisedUrlsConfig(localisedUrls);
|
|
214
214
|
if (localisedUrlsConfig.enabled) {
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
const pathWithoutLanguage = remainingPath.split('/').filter(Boolean).slice(1).join('/');
|
|
218
|
-
const canonicalLocalizedPath = resolveLocalisedPath(`/${pathWithoutLanguage}`, language, languages, localisedUrlsConfig.map);
|
|
219
|
-
const expectedPathname = '/' === basePath ? `/${language}${'/' === canonicalLocalizedPath ? '' : canonicalLocalizedPath}` : `${basePath}/${language}${'/' === canonicalLocalizedPath ? '' : canonicalLocalizedPath}`;
|
|
220
|
-
if (expectedPathname !== pathname) return c.redirect(`${expectedPathname}${url.search}${url.hash}`);
|
|
215
|
+
const expectedUrl = buildLocalizedUrl(c.req, originUrlPath, language, languages, localisedUrls);
|
|
216
|
+
if (expectedUrl !== `${pathname}${url.search}${url.hash}`) return c.redirect(expectedUrl);
|
|
221
217
|
}
|
|
222
218
|
await next();
|
|
223
219
|
}
|
|
@@ -213,12 +213,8 @@ const i18nServerPlugin = (options)=>({
|
|
|
213
213
|
}
|
|
214
214
|
const localisedUrlsConfig = resolveLocalisedUrlsConfig(localisedUrls);
|
|
215
215
|
if (localisedUrlsConfig.enabled) {
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
const pathWithoutLanguage = remainingPath.split('/').filter(Boolean).slice(1).join('/');
|
|
219
|
-
const canonicalLocalizedPath = resolveLocalisedPath(`/${pathWithoutLanguage}`, language, languages, localisedUrlsConfig.map);
|
|
220
|
-
const expectedPathname = '/' === basePath ? `/${language}${'/' === canonicalLocalizedPath ? '' : canonicalLocalizedPath}` : `${basePath}/${language}${'/' === canonicalLocalizedPath ? '' : canonicalLocalizedPath}`;
|
|
221
|
-
if (expectedPathname !== pathname) return c.redirect(`${expectedPathname}${url.search}${url.hash}`);
|
|
216
|
+
const expectedUrl = buildLocalizedUrl(c.req, originUrlPath, language, languages, localisedUrls);
|
|
217
|
+
if (expectedUrl !== `${pathname}${url.search}${url.hash}`) return c.redirect(expectedUrl);
|
|
222
218
|
}
|
|
223
219
|
await next();
|
|
224
220
|
}
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"modern",
|
|
18
18
|
"modern.js"
|
|
19
19
|
],
|
|
20
|
-
"version": "3.2.0-ultramodern.
|
|
20
|
+
"version": "3.2.0-ultramodern.25",
|
|
21
21
|
"engines": {
|
|
22
22
|
"node": ">=20"
|
|
23
23
|
},
|
|
@@ -87,15 +87,15 @@
|
|
|
87
87
|
"i18next-fs-backend": "^2.6.6",
|
|
88
88
|
"i18next-http-backend": "^4.0.0",
|
|
89
89
|
"i18next-http-middleware": "^3.9.7",
|
|
90
|
-
"@modern-js/
|
|
91
|
-
"@modern-js/
|
|
92
|
-
"@modern-js/server-
|
|
93
|
-
"@modern-js/
|
|
94
|
-
"@modern-js/
|
|
95
|
-
"@modern-js/
|
|
90
|
+
"@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.2.0-ultramodern.25",
|
|
91
|
+
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.2.0-ultramodern.25",
|
|
92
|
+
"@modern-js/server-runtime": "npm:@bleedingdev/modern-js-server-runtime@3.2.0-ultramodern.25",
|
|
93
|
+
"@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.2.0-ultramodern.25",
|
|
94
|
+
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.2.0-ultramodern.25",
|
|
95
|
+
"@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.2.0-ultramodern.25"
|
|
96
96
|
},
|
|
97
97
|
"peerDependencies": {
|
|
98
|
-
"@modern-js/runtime": "3.2.0-ultramodern.
|
|
98
|
+
"@modern-js/runtime": "3.2.0-ultramodern.25",
|
|
99
99
|
"i18next": ">=25.7.4",
|
|
100
100
|
"react": "^19.2.6",
|
|
101
101
|
"react-dom": "^19.2.6",
|
|
@@ -120,8 +120,8 @@
|
|
|
120
120
|
"react-dom": "^19.2.6",
|
|
121
121
|
"react-i18next": "17.0.8",
|
|
122
122
|
"ts-jest": "^29.4.11",
|
|
123
|
-
"@modern-js/
|
|
124
|
-
"@modern-js/
|
|
123
|
+
"@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.2.0-ultramodern.25",
|
|
124
|
+
"@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.2.0-ultramodern.25"
|
|
125
125
|
},
|
|
126
126
|
"sideEffects": false,
|
|
127
127
|
"publishConfig": {
|
package/src/server/index.ts
CHANGED
|
@@ -490,33 +490,15 @@ export const i18nServerPlugin = (options: I18nPluginOptions): ServerPlugin => ({
|
|
|
490
490
|
const localisedUrlsConfig =
|
|
491
491
|
resolveLocalisedUrlsConfig(localisedUrls);
|
|
492
492
|
if (localisedUrlsConfig.enabled) {
|
|
493
|
-
const
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
: pathname;
|
|
497
|
-
const pathWithoutLanguage = remainingPath
|
|
498
|
-
.split('/')
|
|
499
|
-
.filter(Boolean)
|
|
500
|
-
.slice(1)
|
|
501
|
-
.join('/');
|
|
502
|
-
const canonicalLocalizedPath = resolveLocalisedPath(
|
|
503
|
-
`/${pathWithoutLanguage}`,
|
|
493
|
+
const expectedUrl = buildLocalizedUrl(
|
|
494
|
+
c.req,
|
|
495
|
+
originUrlPath,
|
|
504
496
|
language,
|
|
505
497
|
languages,
|
|
506
|
-
|
|
498
|
+
localisedUrls,
|
|
507
499
|
);
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
? `/${language}${canonicalLocalizedPath === '/' ? '' : canonicalLocalizedPath}`
|
|
511
|
-
: `${basePath}/${language}${
|
|
512
|
-
canonicalLocalizedPath === '/'
|
|
513
|
-
? ''
|
|
514
|
-
: canonicalLocalizedPath
|
|
515
|
-
}`;
|
|
516
|
-
if (expectedPathname !== pathname) {
|
|
517
|
-
return c.redirect(
|
|
518
|
-
`${expectedPathname}${url.search}${url.hash}`,
|
|
519
|
-
);
|
|
500
|
+
if (expectedUrl !== `${pathname}${url.search}${url.hash}`) {
|
|
501
|
+
return c.redirect(expectedUrl);
|
|
520
502
|
}
|
|
521
503
|
}
|
|
522
504
|
await next();
|