@bleedingdev/modern-js-i18n-runtime-extensions 3.9.0-ultramodern.8 → 3.9.0-ultramodern.9
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/localisedUrls/redirect.js +3 -6
- package/dist/esm/localisedUrls/redirect.mjs +3 -6
- package/dist/esm-node/localisedUrls/redirect.mjs +3 -6
- package/dist/types/localisedUrls/redirect.d.ts +8 -0
- package/package.json +4 -4
- package/src/localisedUrls/redirect.ts +16 -2
- package/tests/localeRedirectPolicy.test.ts +11 -0
|
@@ -40,10 +40,6 @@ const DEFAULT_LOCALE_REDIRECT_SKIP_RULES = [
|
|
|
40
40
|
type: 'exact',
|
|
41
41
|
path: '/backend-mf-manifest.json'
|
|
42
42
|
},
|
|
43
|
-
{
|
|
44
|
-
type: 'exact',
|
|
45
|
-
path: '/backendRemoteEntry.cjs'
|
|
46
|
-
},
|
|
47
43
|
{
|
|
48
44
|
type: 'exact',
|
|
49
45
|
path: '/mf-manifest.json'
|
|
@@ -53,8 +49,8 @@ const DEFAULT_LOCALE_REDIRECT_SKIP_RULES = [
|
|
|
53
49
|
path: '/mf-stats.json'
|
|
54
50
|
},
|
|
55
51
|
{
|
|
56
|
-
type: '
|
|
57
|
-
path:
|
|
52
|
+
type: 'pattern',
|
|
53
|
+
path: /^\/(?:backendRemoteEntry(?:\.[a-zA-Z0-9_-]+)?\.cjs|remoteEntry(?:\.[a-zA-Z0-9_-]+)?\.js)$/
|
|
58
54
|
},
|
|
59
55
|
{
|
|
60
56
|
type: 'prefix',
|
|
@@ -73,6 +69,7 @@ const matchesPathPrefix = (pathname, prefix)=>{
|
|
|
73
69
|
};
|
|
74
70
|
const matchesSkipRule = (pathname, rule)=>{
|
|
75
71
|
if ('exact' === rule.type) return (0, external_normalise_js_namespaceObject.normalisePathname)(pathname) === (0, external_normalise_js_namespaceObject.normalisePathname)(rule.path);
|
|
72
|
+
if ('pattern' === rule.type) return rule.path.test((0, external_normalise_js_namespaceObject.normalisePathname)(pathname));
|
|
76
73
|
return matchesPathPrefix(pathname, rule.path);
|
|
77
74
|
};
|
|
78
75
|
const isDefaultLocaleRedirectSkipPath = (pathname, languages = [])=>{
|
|
@@ -5,10 +5,6 @@ const DEFAULT_LOCALE_REDIRECT_SKIP_RULES = [
|
|
|
5
5
|
type: 'exact',
|
|
6
6
|
path: '/backend-mf-manifest.json'
|
|
7
7
|
},
|
|
8
|
-
{
|
|
9
|
-
type: 'exact',
|
|
10
|
-
path: '/backendRemoteEntry.cjs'
|
|
11
|
-
},
|
|
12
8
|
{
|
|
13
9
|
type: 'exact',
|
|
14
10
|
path: '/mf-manifest.json'
|
|
@@ -18,8 +14,8 @@ const DEFAULT_LOCALE_REDIRECT_SKIP_RULES = [
|
|
|
18
14
|
path: '/mf-stats.json'
|
|
19
15
|
},
|
|
20
16
|
{
|
|
21
|
-
type: '
|
|
22
|
-
path:
|
|
17
|
+
type: 'pattern',
|
|
18
|
+
path: /^\/(?:backendRemoteEntry(?:\.[a-zA-Z0-9_-]+)?\.cjs|remoteEntry(?:\.[a-zA-Z0-9_-]+)?\.js)$/
|
|
23
19
|
},
|
|
24
20
|
{
|
|
25
21
|
type: 'prefix',
|
|
@@ -38,6 +34,7 @@ const matchesPathPrefix = (pathname, prefix)=>{
|
|
|
38
34
|
};
|
|
39
35
|
const matchesSkipRule = (pathname, rule)=>{
|
|
40
36
|
if ('exact' === rule.type) return normalisePathname(pathname) === normalisePathname(rule.path);
|
|
37
|
+
if ('pattern' === rule.type) return rule.path.test(normalisePathname(pathname));
|
|
41
38
|
return matchesPathPrefix(pathname, rule.path);
|
|
42
39
|
};
|
|
43
40
|
const isDefaultLocaleRedirectSkipPath = (pathname, languages = [])=>{
|
|
@@ -6,10 +6,6 @@ const DEFAULT_LOCALE_REDIRECT_SKIP_RULES = [
|
|
|
6
6
|
type: 'exact',
|
|
7
7
|
path: '/backend-mf-manifest.json'
|
|
8
8
|
},
|
|
9
|
-
{
|
|
10
|
-
type: 'exact',
|
|
11
|
-
path: '/backendRemoteEntry.cjs'
|
|
12
|
-
},
|
|
13
9
|
{
|
|
14
10
|
type: 'exact',
|
|
15
11
|
path: '/mf-manifest.json'
|
|
@@ -19,8 +15,8 @@ const DEFAULT_LOCALE_REDIRECT_SKIP_RULES = [
|
|
|
19
15
|
path: '/mf-stats.json'
|
|
20
16
|
},
|
|
21
17
|
{
|
|
22
|
-
type: '
|
|
23
|
-
path:
|
|
18
|
+
type: 'pattern',
|
|
19
|
+
path: /^\/(?:backendRemoteEntry(?:\.[a-zA-Z0-9_-]+)?\.cjs|remoteEntry(?:\.[a-zA-Z0-9_-]+)?\.js)$/
|
|
24
20
|
},
|
|
25
21
|
{
|
|
26
22
|
type: 'prefix',
|
|
@@ -39,6 +35,7 @@ const matchesPathPrefix = (pathname, prefix)=>{
|
|
|
39
35
|
};
|
|
40
36
|
const matchesSkipRule = (pathname, rule)=>{
|
|
41
37
|
if ('exact' === rule.type) return normalisePathname(pathname) === normalisePathname(rule.path);
|
|
38
|
+
if ('pattern' === rule.type) return rule.path.test(normalisePathname(pathname));
|
|
42
39
|
return matchesPathPrefix(pathname, rule.path);
|
|
43
40
|
};
|
|
44
41
|
const isDefaultLocaleRedirectSkipPath = (pathname, languages = [])=>{
|
|
@@ -4,7 +4,15 @@ export type LocaleRedirectSkipRule = {
|
|
|
4
4
|
} | {
|
|
5
5
|
type: 'prefix';
|
|
6
6
|
path: string;
|
|
7
|
+
} | {
|
|
8
|
+
type: 'pattern';
|
|
9
|
+
path: RegExp;
|
|
7
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* Federation artifacts are never pages. The remote entries match the same
|
|
13
|
+
* shapes the federation layer itself recognises and serves (`mfCache.ts`):
|
|
14
|
+
* a manifest may name a root entry such as `remoteEntry.catalog.js`.
|
|
15
|
+
*/
|
|
8
16
|
export declare const DEFAULT_LOCALE_REDIRECT_SKIP_RULES: readonly LocaleRedirectSkipRule[];
|
|
9
17
|
export declare const matchesPathPrefix: (pathname: string, prefix: string) => boolean;
|
|
10
18
|
export declare const isDefaultLocaleRedirectSkipPath: (pathname: string, languages?: string[]) => boolean;
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"modern.js",
|
|
18
18
|
"i18n"
|
|
19
19
|
],
|
|
20
|
-
"version": "3.9.0-ultramodern.
|
|
20
|
+
"version": "3.9.0-ultramodern.9",
|
|
21
21
|
"types": "./dist/types/index.d.ts",
|
|
22
22
|
"main": "./dist/cjs/index.js",
|
|
23
23
|
"module": "./dist/esm/index.mjs",
|
|
@@ -55,15 +55,15 @@
|
|
|
55
55
|
"node": ">=26.7.0"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.9.0-ultramodern.
|
|
58
|
+
"@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.9.0-ultramodern.9",
|
|
59
59
|
"i18next-browser-languagedetector": "^8.2.1"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
|
-
"@modern-js/runtime": "3.9.0-ultramodern.
|
|
62
|
+
"@modern-js/runtime": "3.9.0-ultramodern.9",
|
|
63
63
|
"react": "^19.2.8"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.9.0-ultramodern.
|
|
66
|
+
"@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.9.0-ultramodern.9",
|
|
67
67
|
"@rslib/core": "1.0.0",
|
|
68
68
|
"@scripts/rstest-config": "2.66.0",
|
|
69
69
|
"@types/node": "^26.4.1",
|
|
@@ -9,15 +9,26 @@ export type LocaleRedirectSkipRule =
|
|
|
9
9
|
| {
|
|
10
10
|
type: 'prefix';
|
|
11
11
|
path: string;
|
|
12
|
+
}
|
|
13
|
+
| {
|
|
14
|
+
type: 'pattern';
|
|
15
|
+
path: RegExp;
|
|
12
16
|
};
|
|
13
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Federation artifacts are never pages. The remote entries match the same
|
|
20
|
+
* shapes the federation layer itself recognises and serves (`mfCache.ts`):
|
|
21
|
+
* a manifest may name a root entry such as `remoteEntry.catalog.js`.
|
|
22
|
+
*/
|
|
14
23
|
export const DEFAULT_LOCALE_REDIRECT_SKIP_RULES: readonly LocaleRedirectSkipRule[] =
|
|
15
24
|
[
|
|
16
25
|
{ type: 'exact', path: '/backend-mf-manifest.json' },
|
|
17
|
-
{ type: 'exact', path: '/backendRemoteEntry.cjs' },
|
|
18
26
|
{ type: 'exact', path: '/mf-manifest.json' },
|
|
19
27
|
{ type: 'exact', path: '/mf-stats.json' },
|
|
20
|
-
{
|
|
28
|
+
{
|
|
29
|
+
type: 'pattern',
|
|
30
|
+
path: /^\/(?:backendRemoteEntry(?:\.[a-zA-Z0-9_-]+)?\.cjs|remoteEntry(?:\.[a-zA-Z0-9_-]+)?\.js)$/,
|
|
31
|
+
},
|
|
21
32
|
{ type: 'prefix', path: '/static/' },
|
|
22
33
|
{ type: 'prefix', path: '/upload/' },
|
|
23
34
|
];
|
|
@@ -45,6 +56,9 @@ const matchesSkipRule = (
|
|
|
45
56
|
if (rule.type === 'exact') {
|
|
46
57
|
return normalisePathname(pathname) === normalisePathname(rule.path);
|
|
47
58
|
}
|
|
59
|
+
if (rule.type === 'pattern') {
|
|
60
|
+
return rule.path.test(normalisePathname(pathname));
|
|
61
|
+
}
|
|
48
62
|
|
|
49
63
|
return matchesPathPrefix(pathname, rule.path);
|
|
50
64
|
};
|
|
@@ -21,6 +21,9 @@ describe('locale redirect resource policy', () => {
|
|
|
21
21
|
'/mf-manifest.json',
|
|
22
22
|
'/mf-stats.json',
|
|
23
23
|
'/remoteEntry.js',
|
|
24
|
+
// A manifest may name a root entry; the federation layer serves these.
|
|
25
|
+
'/remoteEntry.catalog.js',
|
|
26
|
+
'/backendRemoteEntry.catalog-v2.cjs',
|
|
24
27
|
'/static/app.js',
|
|
25
28
|
'/upload/avatar.png',
|
|
26
29
|
];
|
|
@@ -32,6 +35,14 @@ describe('locale redirect resource policy', () => {
|
|
|
32
35
|
);
|
|
33
36
|
expect(shouldIgnoreRedirect(`/store${pathname}`, '/store/*')).toBe(true);
|
|
34
37
|
}
|
|
38
|
+
// Only the entry itself, not a page or asset that merely starts like one.
|
|
39
|
+
for (const pathname of [
|
|
40
|
+
'/remoteEntry.catalog.js.map',
|
|
41
|
+
'/remoteEntry.catalog/js',
|
|
42
|
+
'/products/remoteEntry.js',
|
|
43
|
+
]) {
|
|
44
|
+
expect(isStaticResourceRequest(pathname, [], languages)).toBe(false);
|
|
45
|
+
}
|
|
35
46
|
});
|
|
36
47
|
|
|
37
48
|
test('configured static prefixes match complete path segments with or without a locale', () => {
|