@bleedingdev/modern-js-i18n-runtime-extensions 3.9.0-ultramodern.2 → 3.9.0-ultramodern.21
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/index.js +15 -8
- package/dist/cjs/localeRedirectPolicy.js +96 -0
- package/dist/cjs/paths.js +56 -0
- package/dist/cjs/router-navigation/adapter.js +93 -0
- package/dist/cjs/{localisedUrls/config.js → router-navigation/index.js} +5 -14
- package/dist/esm/index.mjs +2 -1
- package/dist/esm/localeRedirectPolicy.mjs +46 -0
- package/dist/esm/paths.mjs +12 -0
- package/dist/esm/router-navigation/adapter.mjs +55 -0
- package/dist/esm/router-navigation/index.mjs +1 -0
- package/dist/esm-node/index.mjs +2 -1
- package/dist/esm-node/localeRedirectPolicy.mjs +47 -0
- package/dist/esm-node/paths.mjs +13 -0
- package/dist/esm-node/router-navigation/adapter.mjs +56 -0
- package/dist/esm-node/router-navigation/index.mjs +2 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/localeRedirectPolicy.d.ts +22 -0
- package/dist/types/paths.d.ts +9 -0
- package/dist/types/router-navigation/adapter.d.ts +23 -0
- package/dist/types/router-navigation/index.d.ts +1 -0
- package/package.json +33 -9
- package/src/index.ts +2 -1
- package/src/localeRedirectPolicy.ts +127 -0
- package/src/paths.ts +37 -0
- package/src/router-navigation/adapter.tsx +120 -0
- package/src/router-navigation/index.ts +6 -0
- package/tests/languageSyncController.test.ts +0 -77
- package/tests/localeRedirectPolicy.test.ts +173 -0
- package/tests/paths.test.ts +24 -0
- package/tests/reactLanguageSync.test.tsx +21 -2
- package/tests/routerNavigation.test.tsx +80 -0
- package/dist/cjs/localisedUrls/index.js +0 -91
- package/dist/cjs/localisedUrls/normalise.js +0 -87
- package/dist/cjs/localisedUrls/pathname.js +0 -68
- package/dist/cjs/localisedUrls/patterns.js +0 -214
- package/dist/cjs/localisedUrls/redirect.js +0 -103
- package/dist/cjs/localisedUrls/resolve.js +0 -78
- package/dist/cjs/localisedUrls/routes.js +0 -202
- package/dist/cjs/localisedUrls/types.js +0 -18
- package/dist/esm/localisedUrls/config.mjs +0 -11
- package/dist/esm/localisedUrls/index.mjs +0 -7
- package/dist/esm/localisedUrls/normalise.mjs +0 -37
- package/dist/esm/localisedUrls/pathname.mjs +0 -24
- package/dist/esm/localisedUrls/patterns.mjs +0 -152
- package/dist/esm/localisedUrls/redirect.mjs +0 -56
- package/dist/esm/localisedUrls/resolve.mjs +0 -37
- package/dist/esm/localisedUrls/routes.mjs +0 -161
- package/dist/esm/localisedUrls/types.mjs +0 -0
- package/dist/esm-node/localisedUrls/config.mjs +0 -12
- package/dist/esm-node/localisedUrls/index.mjs +0 -8
- package/dist/esm-node/localisedUrls/normalise.mjs +0 -38
- package/dist/esm-node/localisedUrls/pathname.mjs +0 -25
- package/dist/esm-node/localisedUrls/patterns.mjs +0 -153
- package/dist/esm-node/localisedUrls/redirect.mjs +0 -57
- package/dist/esm-node/localisedUrls/resolve.mjs +0 -38
- package/dist/esm-node/localisedUrls/routes.mjs +0 -162
- package/dist/esm-node/localisedUrls/types.mjs +0 -1
- package/dist/types/localisedUrls/config.d.ts +0 -9
- package/dist/types/localisedUrls/index.d.ts +0 -9
- package/dist/types/localisedUrls/normalise.d.ts +0 -10
- package/dist/types/localisedUrls/pathname.d.ts +0 -4
- package/dist/types/localisedUrls/patterns.d.ts +0 -11
- package/dist/types/localisedUrls/redirect.d.ts +0 -11
- package/dist/types/localisedUrls/resolve.d.ts +0 -7
- package/dist/types/localisedUrls/routes.d.ts +0 -3
- package/dist/types/localisedUrls/types.d.ts +0 -14
- package/src/localisedUrls/config.ts +0 -18
- package/src/localisedUrls/index.ts +0 -24
- package/src/localisedUrls/normalise.ts +0 -62
- package/src/localisedUrls/pathname.ts +0 -60
- package/src/localisedUrls/patterns.ts +0 -283
- package/src/localisedUrls/redirect.ts +0 -93
- package/src/localisedUrls/resolve.ts +0 -106
- package/src/localisedUrls/routes.ts +0 -422
- package/src/localisedUrls/types.ts +0 -18
- package/tests/clientRedirectIntegration.test.tsx +0 -74
- package/tests/localisedUrls.test.ts +0 -673
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { normalisePathname } from "./normalise.mjs";
|
|
2
|
-
import { stripLanguagePrefix } from "./pathname.mjs";
|
|
3
|
-
const DEFAULT_LOCALE_REDIRECT_SKIP_RULES = [
|
|
4
|
-
{
|
|
5
|
-
type: 'exact',
|
|
6
|
-
path: '/backend-mf-manifest.json'
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
type: 'exact',
|
|
10
|
-
path: '/backendRemoteEntry.cjs'
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
type: 'exact',
|
|
14
|
-
path: '/mf-manifest.json'
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
type: 'exact',
|
|
18
|
-
path: '/mf-stats.json'
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
type: 'exact',
|
|
22
|
-
path: '/remoteEntry.js'
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
type: 'prefix',
|
|
26
|
-
path: '/static/'
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
type: 'prefix',
|
|
30
|
-
path: '/upload/'
|
|
31
|
-
}
|
|
32
|
-
];
|
|
33
|
-
const stripTrailingSlash = (pathname)=>pathname.length > 1 ? pathname.replace(/\/+$/, '') : pathname;
|
|
34
|
-
const matchesPathPrefix = (pathname, prefix)=>{
|
|
35
|
-
const normalizedPathname = normalisePathname(pathname);
|
|
36
|
-
const normalizedPrefix = stripTrailingSlash(normalisePathname(prefix));
|
|
37
|
-
return normalizedPathname === normalizedPrefix || normalizedPathname.startsWith(`${normalizedPrefix}/`);
|
|
38
|
-
};
|
|
39
|
-
const matchesSkipRule = (pathname, rule)=>{
|
|
40
|
-
if ('exact' === rule.type) return normalisePathname(pathname) === normalisePathname(rule.path);
|
|
41
|
-
return matchesPathPrefix(pathname, rule.path);
|
|
42
|
-
};
|
|
43
|
-
const isDefaultLocaleRedirectSkipPath = (pathname, languages = [])=>{
|
|
44
|
-
const normalizedPathname = normalisePathname(pathname);
|
|
45
|
-
const pathWithoutLanguage = stripLanguagePrefix(normalizedPathname, languages);
|
|
46
|
-
return DEFAULT_LOCALE_REDIRECT_SKIP_RULES.some((rule)=>matchesSkipRule(pathWithoutLanguage, rule));
|
|
47
|
-
};
|
|
48
|
-
const shouldSkipLocaleRedirect = (pathname, languages = [], ignoreRedirectRoutes)=>{
|
|
49
|
-
const normalizedPathname = normalisePathname(pathname);
|
|
50
|
-
const pathWithoutLanguage = stripLanguagePrefix(normalizedPathname, languages);
|
|
51
|
-
if (isDefaultLocaleRedirectSkipPath(pathWithoutLanguage)) return true;
|
|
52
|
-
if (!ignoreRedirectRoutes) return false;
|
|
53
|
-
if ('function' == typeof ignoreRedirectRoutes) return ignoreRedirectRoutes(pathWithoutLanguage);
|
|
54
|
-
return ignoreRedirectRoutes.some((pattern)=>matchesPathPrefix(pathWithoutLanguage, pattern));
|
|
55
|
-
};
|
|
56
|
-
export { DEFAULT_LOCALE_REDIRECT_SKIP_RULES, isDefaultLocaleRedirectSkipPath, matchesPathPrefix, shouldSkipLocaleRedirect };
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { normalisePathname } from "./normalise.mjs";
|
|
2
|
-
import { buildPathFromPattern, matchPathPattern, sortPatternsBySpecificity } from "./patterns.mjs";
|
|
3
|
-
const getCanonicalCandidates = (localisedUrls)=>sortPatternsBySpecificity(Object.entries(localisedUrls).map(([canonicalPattern, localisedUrlEntry])=>({
|
|
4
|
-
pattern: canonicalPattern,
|
|
5
|
-
canonicalPattern,
|
|
6
|
-
localisedUrlEntry
|
|
7
|
-
})));
|
|
8
|
-
const resolveLocalisedUrlPath = (pathname, languages, localisedUrls, options)=>{
|
|
9
|
-
const normalizedPathname = normalisePathname(pathname);
|
|
10
|
-
const canonicalCandidates = getCanonicalCandidates(localisedUrls);
|
|
11
|
-
const candidates = sortPatternsBySpecificity(canonicalCandidates.flatMap(({ canonicalPattern, localisedUrlEntry })=>{
|
|
12
|
-
const targetPattern = 'localised' === options.mode ? localisedUrlEntry[options.targetLanguage] : canonicalPattern;
|
|
13
|
-
if (!targetPattern) return [];
|
|
14
|
-
const sourcePatterns = new Set([
|
|
15
|
-
canonicalPattern,
|
|
16
|
-
...languages.map((language)=>localisedUrlEntry[language]).filter((sourcePattern)=>Boolean(sourcePattern))
|
|
17
|
-
]);
|
|
18
|
-
return Array.from(sourcePatterns, (sourcePattern)=>({
|
|
19
|
-
pattern: sourcePattern,
|
|
20
|
-
sourcePattern,
|
|
21
|
-
targetPattern
|
|
22
|
-
}));
|
|
23
|
-
}));
|
|
24
|
-
for (const { sourcePattern, targetPattern } of candidates){
|
|
25
|
-
const params = matchPathPattern(normalizedPathname, sourcePattern);
|
|
26
|
-
if (params) return buildPathFromPattern(targetPattern, params);
|
|
27
|
-
}
|
|
28
|
-
return normalizedPathname;
|
|
29
|
-
};
|
|
30
|
-
const resolveLocalisedPath = (pathname, targetLanguage, languages, localisedUrls)=>resolveLocalisedUrlPath(pathname, languages, localisedUrls, {
|
|
31
|
-
mode: 'localised',
|
|
32
|
-
targetLanguage
|
|
33
|
-
});
|
|
34
|
-
const resolveCanonicalLocalisedPath = (pathname, languages, localisedUrls)=>resolveLocalisedUrlPath(pathname, languages, localisedUrls, {
|
|
35
|
-
mode: 'canonical'
|
|
36
|
-
});
|
|
37
|
-
export { resolveCanonicalLocalisedPath, resolveLocalisedPath };
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { getLeadingLocaleParam, normalisePathPattern, normaliseRoutePath, stripLeadingLocaleParam } from "./normalise.mjs";
|
|
2
|
-
import { doPathPatternsOverlap, getOrderedPathParamSignature, getPathParamSignature, getPathPatternValidationIssue, getPhysicalPathPattern, haveEqualPatternSpecificity } from "./patterns.mjs";
|
|
3
|
-
const isLocalisableRoutePath = (path)=>{
|
|
4
|
-
const pathWithoutLocale = stripLeadingLocaleParam(path);
|
|
5
|
-
if (!pathWithoutLocale || '/' === pathWithoutLocale || '*' === pathWithoutLocale) return false;
|
|
6
|
-
return true;
|
|
7
|
-
};
|
|
8
|
-
const joinPath = (parentPath, routePath)=>{
|
|
9
|
-
if (!isLocalisableRoutePath(routePath)) return parentPath;
|
|
10
|
-
const segment = normaliseRoutePath(stripLeadingLocaleParam(routePath) || '');
|
|
11
|
-
return normalisePathPattern(`${parentPath}/${segment}`);
|
|
12
|
-
};
|
|
13
|
-
const isFrameworkInternalRoutePath = (canonicalPath)=>'/_mf' === canonicalPath || canonicalPath.startsWith('/_mf/');
|
|
14
|
-
const legalRouteIdPart = (value)=>value.replace(/[^a-zA-Z0-9_$-]+/g, '_').replace(/^_+|_+$/g, '') || 'index';
|
|
15
|
-
const formatParamSignature = (signature)=>signature.length > 0 ? signature.join(', ') : '(none)';
|
|
16
|
-
const validateLocalisedUrlPatterns = (languages, localisedUrls)=>{
|
|
17
|
-
const physicalPatterns = new Map();
|
|
18
|
-
const claimedPatterns = [];
|
|
19
|
-
const claimPhysicalPattern = (sourcePattern, canonicalPath, source)=>{
|
|
20
|
-
const physicalPattern = getPhysicalPathPattern(sourcePattern);
|
|
21
|
-
const existing = physicalPatterns.get(physicalPattern);
|
|
22
|
-
if (existing && existing.canonicalPath !== canonicalPath) throw new Error(`localisedUrls["${existing.canonicalPath}"] ${existing.source} and localisedUrls["${canonicalPath}"] ${source} generate the same physical route pattern "${physicalPattern}". Localised route patterns must identify exactly one canonical route.`);
|
|
23
|
-
const overlapping = claimedPatterns.find((claimed)=>claimed.canonicalPath !== canonicalPath && haveEqualPatternSpecificity(claimed.pattern, sourcePattern) && doPathPatternsOverlap(claimed.pattern, sourcePattern));
|
|
24
|
-
if (overlapping) throw new Error(`localisedUrls["${overlapping.canonicalPath}"] ${overlapping.source} pattern "${overlapping.pattern}" and localisedUrls["${canonicalPath}"] ${source} pattern "${sourcePattern}" are equal-specificity overlapping route patterns. Localised route patterns must identify exactly one canonical route.`);
|
|
25
|
-
physicalPatterns.set(physicalPattern, {
|
|
26
|
-
canonicalPath,
|
|
27
|
-
source
|
|
28
|
-
});
|
|
29
|
-
claimedPatterns.push({
|
|
30
|
-
canonicalPath,
|
|
31
|
-
pattern: sourcePattern,
|
|
32
|
-
source
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
for (const [canonicalPath, entry] of Object.entries(localisedUrls).sort(([left], [right])=>left < right ? -1 : left > right ? 1 : 0)){
|
|
36
|
-
const canonicalIssue = getPathPatternValidationIssue(canonicalPath);
|
|
37
|
-
if (canonicalIssue) throw new Error(`localisedUrls["${canonicalPath}"] canonical pattern has ${canonicalIssue}.`);
|
|
38
|
-
const expectedSignature = getPathParamSignature(canonicalPath);
|
|
39
|
-
const expectedOrderedSignature = getOrderedPathParamSignature(canonicalPath);
|
|
40
|
-
claimPhysicalPattern(canonicalPath, canonicalPath, 'canonical pattern');
|
|
41
|
-
for (const language of languages){
|
|
42
|
-
const localisedPattern = entry[language];
|
|
43
|
-
if (!localisedPattern) continue;
|
|
44
|
-
const localisedIssue = getPathPatternValidationIssue(localisedPattern);
|
|
45
|
-
if (localisedIssue) throw new Error(`localisedUrls["${canonicalPath}"].${language} has ${localisedIssue}.`);
|
|
46
|
-
const actualSignature = getPathParamSignature(localisedPattern);
|
|
47
|
-
if (actualSignature.length !== expectedSignature.length || actualSignature.some((parameter, index)=>parameter !== expectedSignature[index])) throw new Error(`localisedUrls["${canonicalPath}"].${language} must use the same parameter signature as "${canonicalPath}": expected ${formatParamSignature(expectedSignature)}; received ${formatParamSignature(actualSignature)}.`);
|
|
48
|
-
const actualOrderedSignature = getOrderedPathParamSignature(localisedPattern);
|
|
49
|
-
if (expectedOrderedSignature.some((parameter)=>'*' === parameter || parameter.endsWith('?')) && actualOrderedSignature.some((parameter, index)=>parameter !== expectedOrderedSignature[index])) throw new Error(`localisedUrls["${canonicalPath}"].${language} must keep optional and splat parameters in canonical order: expected ${formatParamSignature(expectedOrderedSignature)}; received ${formatParamSignature(actualOrderedSignature)}.`);
|
|
50
|
-
claimPhysicalPattern(localisedPattern, canonicalPath, `.${language}`);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
const ensureLocalisedUrlsForPath = (canonicalPath, languages, localisedUrls)=>{
|
|
55
|
-
const entry = localisedUrls[canonicalPath];
|
|
56
|
-
if (!entry) throw new Error(`localisedUrls is enabled, but route "${canonicalPath}" does not define localised URLs for languages: ${languages.join(', ')}. Add localisedUrls["${canonicalPath}"] or set localeDetection.localisedUrls to false.`);
|
|
57
|
-
const missingLanguages = languages.filter((language)=>!entry[language]);
|
|
58
|
-
if (missingLanguages.length > 0) throw new Error(`localisedUrls["${canonicalPath}"] is missing languages: ${missingLanguages.join(', ')}. Every configured language must have a localised URL.`);
|
|
59
|
-
return entry;
|
|
60
|
-
};
|
|
61
|
-
const validateLocalisedUrls = (routes, languages, localisedUrls)=>{
|
|
62
|
-
validateLocalisedUrlPatterns(languages, localisedUrls);
|
|
63
|
-
const visit = (route, parentPath)=>{
|
|
64
|
-
const canonicalPath = joinPath(parentPath, route.path);
|
|
65
|
-
if (isLocalisableRoutePath(route.path) && !isFrameworkInternalRoutePath(canonicalPath)) ensureLocalisedUrlsForPath(canonicalPath, languages, localisedUrls);
|
|
66
|
-
if ('children' in route && route.children) route.children.forEach((child)=>visit(child, canonicalPath));
|
|
67
|
-
};
|
|
68
|
-
routes.forEach((route)=>visit(route, ''));
|
|
69
|
-
};
|
|
70
|
-
const getLocalisedRouteIdSuffixes = (paths)=>{
|
|
71
|
-
const usedSuffixes = new Set();
|
|
72
|
-
return paths.map((path, index)=>{
|
|
73
|
-
if (0 === index) return;
|
|
74
|
-
const baseSuffix = legalRouteIdPart(path);
|
|
75
|
-
let suffix = baseSuffix;
|
|
76
|
-
let disambiguator = 2;
|
|
77
|
-
while(usedSuffixes.has(suffix))suffix = `${baseSuffix}_${disambiguator++}`;
|
|
78
|
-
usedSuffixes.add(suffix);
|
|
79
|
-
return suffix;
|
|
80
|
-
});
|
|
81
|
-
};
|
|
82
|
-
const getLocalisedRoutePaths = (canonicalPath, parentLocalisedPaths, languages, entry)=>{
|
|
83
|
-
const paths = languages.map((language)=>{
|
|
84
|
-
const fullPath = normalisePathPattern(entry[language]);
|
|
85
|
-
const parentPath = normalisePathPattern(parentLocalisedPaths[language] || '/');
|
|
86
|
-
if ('/' === parentPath) return normaliseRoutePath(fullPath) || void 0;
|
|
87
|
-
const parentPrefix = `${parentPath}/`;
|
|
88
|
-
if (!fullPath.startsWith(parentPrefix)) throw new Error(`localisedUrls["${canonicalPath}"].${language} must be nested under "${parentPath}" because its parent route is localised there.`);
|
|
89
|
-
return normaliseRoutePath(fullPath.slice(parentPath.length));
|
|
90
|
-
});
|
|
91
|
-
const uniquePaths = Array.from(new Set(paths.filter(Boolean)));
|
|
92
|
-
return uniquePaths;
|
|
93
|
-
};
|
|
94
|
-
const transformLocalisedRoute = (route, parentCanonicalPath, parentLocalisedPaths, languages, localisedUrls)=>{
|
|
95
|
-
const canonicalPath = joinPath(parentCanonicalPath, route.path);
|
|
96
|
-
const localisedUrlEntry = isLocalisableRoutePath(route.path) && !isFrameworkInternalRoutePath(canonicalPath) ? ensureLocalisedUrlsForPath(canonicalPath, languages, localisedUrls) : void 0;
|
|
97
|
-
const routeLocalisedPaths = localisedUrlEntry ? languages.reduce((acc, language)=>{
|
|
98
|
-
acc[language] = normalisePathPattern(localisedUrlEntry[language]);
|
|
99
|
-
return acc;
|
|
100
|
-
}, {}) : parentLocalisedPaths;
|
|
101
|
-
const children = 'children' in route && route.children ? route.children.flatMap((child)=>transformLocalisedRoute(child, canonicalPath, routeLocalisedPaths, languages, localisedUrls)) : void 0;
|
|
102
|
-
const baseRoute = {
|
|
103
|
-
...route,
|
|
104
|
-
...children ? {
|
|
105
|
-
children
|
|
106
|
-
} : {}
|
|
107
|
-
};
|
|
108
|
-
if (!localisedUrlEntry) return [
|
|
109
|
-
baseRoute
|
|
110
|
-
];
|
|
111
|
-
const localisedPaths = getLocalisedRoutePaths(canonicalPath, parentLocalisedPaths, languages, localisedUrlEntry);
|
|
112
|
-
const leadingLocaleParam = getLeadingLocaleParam(route.path);
|
|
113
|
-
const routeIdPaths = leadingLocaleParam ? localisedPaths.map((path)=>normaliseRoutePath(`${leadingLocaleParam}/${path}`)) : localisedPaths;
|
|
114
|
-
const routeIdSuffixes = getLocalisedRouteIdSuffixes(routeIdPaths);
|
|
115
|
-
return localisedPaths.map((localisedPath, index)=>cloneRouteWithLocalisedPath(baseRoute, localisedPath, routeIdSuffixes[index], canonicalPath));
|
|
116
|
-
};
|
|
117
|
-
const suffixRouteIds = (route, suffix)=>{
|
|
118
|
-
const children = 'children' in route && route.children ? route.children.map((child)=>suffixRouteIds(child, suffix)) : void 0;
|
|
119
|
-
return {
|
|
120
|
-
...route,
|
|
121
|
-
...route.id ? {
|
|
122
|
-
id: `${route.id}__localised_${suffix}`
|
|
123
|
-
} : {},
|
|
124
|
-
...children ? {
|
|
125
|
-
children
|
|
126
|
-
} : {}
|
|
127
|
-
};
|
|
128
|
-
};
|
|
129
|
-
const collectRouteIdCounts = (routes, counts = new Map())=>{
|
|
130
|
-
for (const route of routes){
|
|
131
|
-
if (route.id) counts.set(route.id, (counts.get(route.id) ?? 0) + 1);
|
|
132
|
-
if ('children' in route && route.children) collectRouteIdCounts(route.children, counts);
|
|
133
|
-
}
|
|
134
|
-
return counts;
|
|
135
|
-
};
|
|
136
|
-
const validateNoNewRouteIdCollisions = (sourceRoutes, localisedRoutes)=>{
|
|
137
|
-
const sourceCounts = collectRouteIdCounts(sourceRoutes);
|
|
138
|
-
const localisedCounts = collectRouteIdCounts(localisedRoutes);
|
|
139
|
-
for (const [routeId, count] of localisedCounts)if (count > 1 && count > (sourceCounts.get(routeId) ?? 0)) throw new Error(`Localised route expansion generated duplicate route ID "${routeId}". Change the source route ID or localised path so every generated route remains identifiable.`);
|
|
140
|
-
};
|
|
141
|
-
const cloneRouteWithLocalisedPath = (route, path, routeIdSuffix, canonicalPath)=>{
|
|
142
|
-
const leadingLocaleParam = getLeadingLocaleParam(route.path);
|
|
143
|
-
const localisedPath = leadingLocaleParam ? normaliseRoutePath(`${leadingLocaleParam}/${path}`) : path;
|
|
144
|
-
const routeWithPath = {
|
|
145
|
-
...route,
|
|
146
|
-
path: localisedPath
|
|
147
|
-
};
|
|
148
|
-
routeWithPath.modernCanonicalPath = canonicalPath;
|
|
149
|
-
return routeIdSuffix ? suffixRouteIds(routeWithPath, routeIdSuffix) : routeWithPath;
|
|
150
|
-
};
|
|
151
|
-
const applyLocalisedUrlsToRoutes = (routes, languages, localisedUrls)=>{
|
|
152
|
-
const rootLocalisedPaths = languages.reduce((acc, language)=>{
|
|
153
|
-
acc[language] = '/';
|
|
154
|
-
return acc;
|
|
155
|
-
}, {});
|
|
156
|
-
validateLocalisedUrls(routes, languages, localisedUrls);
|
|
157
|
-
const localisedRoutes = routes.flatMap((route)=>transformLocalisedRoute(route, '', rootLocalisedPaths, languages, localisedUrls));
|
|
158
|
-
validateNoNewRouteIdCollisions(routes, localisedRoutes);
|
|
159
|
-
return localisedRoutes;
|
|
160
|
-
};
|
|
161
|
-
export { applyLocalisedUrlsToRoutes, validateLocalisedUrls };
|
|
File without changes
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
const resolveLocalisedUrlsConfig = (option)=>{
|
|
3
|
-
if (option && 'object' == typeof option && Object.keys(option).length > 0) return {
|
|
4
|
-
enabled: true,
|
|
5
|
-
map: option
|
|
6
|
-
};
|
|
7
|
-
return {
|
|
8
|
-
enabled: false,
|
|
9
|
-
map: {}
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
export { resolveLocalisedUrlsConfig };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
export { resolveLocalisedUrlsConfig } from "./config.mjs";
|
|
3
|
-
export { normalisePathPattern, normalisePathname } from "./normalise.mjs";
|
|
4
|
-
export { canonicalTargetPathname, localiseTargetPathname, stripLanguagePrefix } from "./pathname.mjs";
|
|
5
|
-
export { buildPathFromPattern, matchPathPattern } from "./patterns.mjs";
|
|
6
|
-
export { DEFAULT_LOCALE_REDIRECT_SKIP_RULES, isDefaultLocaleRedirectSkipPath, matchesPathPrefix, shouldSkipLocaleRedirect } from "./redirect.mjs";
|
|
7
|
-
export { resolveCanonicalLocalisedPath, resolveLocalisedPath } from "./resolve.mjs";
|
|
8
|
-
export { applyLocalisedUrlsToRoutes, validateLocalisedUrls } from "./routes.mjs";
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
const LOCALE_PARAM_NAMES = new Set([
|
|
3
|
-
'lang',
|
|
4
|
-
'locale',
|
|
5
|
-
'language'
|
|
6
|
-
]);
|
|
7
|
-
const normaliseSlashes = (path)=>{
|
|
8
|
-
const withoutDuplicateSlashes = path.replace(/\/+/g, '/');
|
|
9
|
-
const withLeadingSlash = withoutDuplicateSlashes.startsWith('/') ? withoutDuplicateSlashes : `/${withoutDuplicateSlashes}`;
|
|
10
|
-
return withLeadingSlash.length > 1 ? withLeadingSlash.replace(/\/+$/, '') : withLeadingSlash;
|
|
11
|
-
};
|
|
12
|
-
const normalisePathPattern = (path)=>normaliseSlashes(path).replace(/\[(.+?)\]/g, ':$1');
|
|
13
|
-
const normalisePathname = (pathname)=>normaliseSlashes(pathname);
|
|
14
|
-
const normaliseRoutePath = (path)=>{
|
|
15
|
-
const normalized = normalisePathPattern(path);
|
|
16
|
-
return '/' === normalized ? '' : normalized.slice(1);
|
|
17
|
-
};
|
|
18
|
-
const getLocaleParamSegment = (segment)=>{
|
|
19
|
-
if (!segment.startsWith(':')) return null;
|
|
20
|
-
const paramName = segment.slice(1).replace(/\?$/, '');
|
|
21
|
-
return LOCALE_PARAM_NAMES.has(paramName) ? segment : null;
|
|
22
|
-
};
|
|
23
|
-
const splitPathSegments = (path)=>{
|
|
24
|
-
if (!path) return [];
|
|
25
|
-
return normalisePathPattern(path).split('/').filter(Boolean);
|
|
26
|
-
};
|
|
27
|
-
const stripLeadingLocaleParam = (path)=>{
|
|
28
|
-
const segments = splitPathSegments(path);
|
|
29
|
-
const leadingLocaleParam = getLocaleParamSegment(segments[0] || '');
|
|
30
|
-
if (!leadingLocaleParam) return path;
|
|
31
|
-
const remainingPath = segments.slice(1).join('/');
|
|
32
|
-
return remainingPath ? `/${remainingPath}` : void 0;
|
|
33
|
-
};
|
|
34
|
-
const getLeadingLocaleParam = (path)=>{
|
|
35
|
-
const segments = splitPathSegments(path);
|
|
36
|
-
return getLocaleParamSegment(segments[0] || '');
|
|
37
|
-
};
|
|
38
|
-
export { getLeadingLocaleParam, normalisePathPattern, normalisePathname, normaliseRoutePath, stripLeadingLocaleParam };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
import { resolveLocalisedUrlsConfig } from "./config.mjs";
|
|
3
|
-
import { resolveCanonicalLocalisedPath, resolveLocalisedPath } from "./resolve.mjs";
|
|
4
|
-
const stripLanguagePrefix = (pathname, languages)=>{
|
|
5
|
-
const segments = pathname.split('/').filter(Boolean);
|
|
6
|
-
const firstSegment = segments[0]?.toLowerCase();
|
|
7
|
-
if (firstSegment && languages.some((language)=>language.toLowerCase() === firstSegment)) return `/${segments.slice(1).join('/')}`;
|
|
8
|
-
return pathname || '/';
|
|
9
|
-
};
|
|
10
|
-
const localiseTargetPathname = (pathname, language, languages, localisedUrls)=>{
|
|
11
|
-
const pathWithoutLanguage = stripLanguagePrefix(pathname, languages);
|
|
12
|
-
const localisedUrlsConfig = resolveLocalisedUrlsConfig(localisedUrls);
|
|
13
|
-
const resolvedPath = localisedUrlsConfig.enabled ? resolveLocalisedPath(pathWithoutLanguage, language, languages, localisedUrlsConfig.map) : pathWithoutLanguage;
|
|
14
|
-
const resolvedSegments = resolvedPath.split('/').filter(Boolean);
|
|
15
|
-
return `/${[
|
|
16
|
-
language,
|
|
17
|
-
...resolvedSegments
|
|
18
|
-
].join('/')}`;
|
|
19
|
-
};
|
|
20
|
-
const canonicalTargetPathname = (pathname, languages, localisedUrls)=>{
|
|
21
|
-
const pathWithoutLanguage = stripLanguagePrefix(pathname, languages);
|
|
22
|
-
const localisedUrlsConfig = resolveLocalisedUrlsConfig(localisedUrls);
|
|
23
|
-
return localisedUrlsConfig.enabled ? resolveCanonicalLocalisedPath(pathWithoutLanguage, languages, localisedUrlsConfig.map) : pathWithoutLanguage;
|
|
24
|
-
};
|
|
25
|
-
export { canonicalTargetPathname, localiseTargetPathname, stripLanguagePrefix };
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
import { normalisePathPattern, normalisePathname } from "./normalise.mjs";
|
|
3
|
-
const escapeRegExp = (value)=>value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
4
|
-
const getParamName = (segment)=>segment.slice(1).replace(/\?$/, '');
|
|
5
|
-
const getOrderedPathParamSignature = (pattern)=>normalisePathPattern(pattern).split('/').filter(Boolean).flatMap((segment)=>{
|
|
6
|
-
if ('*' === segment) return [
|
|
7
|
-
'*'
|
|
8
|
-
];
|
|
9
|
-
if (!segment.startsWith(':')) return [];
|
|
10
|
-
return [
|
|
11
|
-
`:${getParamName(segment)}${segment.endsWith('?') ? '?' : ''}`
|
|
12
|
-
];
|
|
13
|
-
});
|
|
14
|
-
const getPathParamSignature = (pattern)=>getOrderedPathParamSignature(pattern).sort((left, right)=>left < right ? -1 : left > right ? 1 : 0);
|
|
15
|
-
const getPathPatternValidationIssue = (pattern)=>{
|
|
16
|
-
const segments = normalisePathPattern(pattern).split('/').filter(Boolean);
|
|
17
|
-
const seenParams = new Set();
|
|
18
|
-
for (const [index, segment] of segments.entries()){
|
|
19
|
-
if ('*' === segment) {
|
|
20
|
-
if (index !== segments.length - 1) return 'splat parameter "*" must be the final segment';
|
|
21
|
-
if (seenParams.has('*')) return 'duplicate splat parameter "*"';
|
|
22
|
-
seenParams.add('*');
|
|
23
|
-
continue;
|
|
24
|
-
}
|
|
25
|
-
if (!segment.startsWith(':')) continue;
|
|
26
|
-
const paramName = getParamName(segment);
|
|
27
|
-
if (seenParams.has(paramName)) return `duplicate path parameter ":${paramName}"`;
|
|
28
|
-
seenParams.add(paramName);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
const getPhysicalPathPattern = (pattern)=>{
|
|
32
|
-
const segments = normalisePathPattern(pattern).split('/').filter(Boolean);
|
|
33
|
-
const physicalSegments = segments.map((segment)=>{
|
|
34
|
-
if ('*' === segment) return '*';
|
|
35
|
-
if (segment.startsWith(':')) return segment.endsWith('?') ? ':param?' : ':param';
|
|
36
|
-
return segment;
|
|
37
|
-
});
|
|
38
|
-
return `/${physicalSegments.join('/')}`;
|
|
39
|
-
};
|
|
40
|
-
const compiledPathPatternCache = new Map();
|
|
41
|
-
const compilePathPattern = (pattern)=>{
|
|
42
|
-
const normalizedPattern = normalisePathPattern(pattern);
|
|
43
|
-
const cached = compiledPathPatternCache.get(normalizedPattern);
|
|
44
|
-
if (cached) return cached;
|
|
45
|
-
const names = [];
|
|
46
|
-
const segments = normalizedPattern.split('/').filter(Boolean);
|
|
47
|
-
const source = segments.map((segment)=>{
|
|
48
|
-
if (segment.startsWith(':')) {
|
|
49
|
-
names.push(getParamName(segment));
|
|
50
|
-
const paramPattern = '([^/]+)';
|
|
51
|
-
return segment.endsWith('?') ? `(?:/${paramPattern})?` : `/${paramPattern}`;
|
|
52
|
-
}
|
|
53
|
-
if ('*' === segment) {
|
|
54
|
-
names.push('*');
|
|
55
|
-
return '(?:/(.*))?';
|
|
56
|
-
}
|
|
57
|
-
return `/${escapeRegExp(segment)}`;
|
|
58
|
-
}).join('');
|
|
59
|
-
const compiled = {
|
|
60
|
-
names,
|
|
61
|
-
regexp: new RegExp(`^${source || '/'}$`)
|
|
62
|
-
};
|
|
63
|
-
compiledPathPatternCache.set(normalizedPattern, compiled);
|
|
64
|
-
return compiled;
|
|
65
|
-
};
|
|
66
|
-
const getPatternSpecificity = (pattern)=>{
|
|
67
|
-
const segments = normalisePathPattern(pattern).split('/').filter(Boolean);
|
|
68
|
-
let staticSegments = 0;
|
|
69
|
-
let dynamicSegments = 0;
|
|
70
|
-
let optionalSegments = 0;
|
|
71
|
-
let splatSegments = 0;
|
|
72
|
-
for (const segment of segments)if ('*' === segment) splatSegments++;
|
|
73
|
-
else if (segment.startsWith(':')) {
|
|
74
|
-
dynamicSegments++;
|
|
75
|
-
if (segment.endsWith('?')) optionalSegments++;
|
|
76
|
-
} else staticSegments++;
|
|
77
|
-
return {
|
|
78
|
-
staticSegments,
|
|
79
|
-
dynamicSegments,
|
|
80
|
-
optionalSegments,
|
|
81
|
-
splatSegments,
|
|
82
|
-
totalSegments: segments.length
|
|
83
|
-
};
|
|
84
|
-
};
|
|
85
|
-
const comparePatternSpecificity = (left, right)=>{
|
|
86
|
-
const a = getPatternSpecificity(left);
|
|
87
|
-
const b = getPatternSpecificity(right);
|
|
88
|
-
return b.staticSegments - a.staticSegments || a.splatSegments - b.splatSegments || a.optionalSegments - b.optionalSegments || b.totalSegments - a.totalSegments || a.dynamicSegments - b.dynamicSegments;
|
|
89
|
-
};
|
|
90
|
-
const haveEqualPatternSpecificity = (left, right)=>0 === comparePatternSpecificity(left, right);
|
|
91
|
-
const doPathPatternsOverlap = (left, right)=>{
|
|
92
|
-
const leftSegments = normalisePathPattern(left).split('/').filter(Boolean);
|
|
93
|
-
const rightSegments = normalisePathPattern(right).split('/').filter(Boolean);
|
|
94
|
-
if (leftSegments.length !== rightSegments.length) return false;
|
|
95
|
-
return leftSegments.every((leftSegment, index)=>{
|
|
96
|
-
const rightSegment = rightSegments[index];
|
|
97
|
-
const leftIsDynamic = '*' === leftSegment || leftSegment.startsWith(':');
|
|
98
|
-
const rightIsDynamic = '*' === rightSegment || rightSegment.startsWith(':');
|
|
99
|
-
return leftIsDynamic || rightIsDynamic || leftSegment === rightSegment;
|
|
100
|
-
});
|
|
101
|
-
};
|
|
102
|
-
const comparePatternNames = (left, right)=>{
|
|
103
|
-
const normalizedLeft = normalisePathPattern(left);
|
|
104
|
-
const normalizedRight = normalisePathPattern(right);
|
|
105
|
-
return normalizedLeft < normalizedRight ? -1 : normalizedLeft > normalizedRight ? 1 : 0;
|
|
106
|
-
};
|
|
107
|
-
const sortPatternsBySpecificity = (patterns)=>patterns.map((pattern, index)=>({
|
|
108
|
-
pattern,
|
|
109
|
-
index
|
|
110
|
-
})).sort((left, right)=>comparePatternSpecificity(left.pattern.pattern, right.pattern.pattern) || comparePatternNames(left.pattern.pattern, right.pattern.pattern) || left.index - right.index).map(({ pattern })=>pattern);
|
|
111
|
-
const decodePathParam = (value)=>{
|
|
112
|
-
try {
|
|
113
|
-
return decodeURIComponent(value);
|
|
114
|
-
} catch {
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
const encodeSplatParam = (value)=>value.split('/').map(encodeURIComponent).join('/');
|
|
119
|
-
const matchPathPattern = (pathname, pattern)=>{
|
|
120
|
-
const { names, regexp } = compilePathPattern(pattern);
|
|
121
|
-
const match = regexp.exec(normalisePathname(pathname));
|
|
122
|
-
if (!match) return null;
|
|
123
|
-
const params = {};
|
|
124
|
-
for(let index = 0; index < names.length; index++){
|
|
125
|
-
const decoded = decodePathParam(match[index + 1] || '');
|
|
126
|
-
if (null === decoded) return null;
|
|
127
|
-
Object.defineProperty(params, names[index], {
|
|
128
|
-
configurable: true,
|
|
129
|
-
enumerable: true,
|
|
130
|
-
value: decoded,
|
|
131
|
-
writable: true
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
return params;
|
|
135
|
-
};
|
|
136
|
-
const buildPathFromPattern = (pattern, params)=>{
|
|
137
|
-
const segments = normalisePathPattern(pattern).split('/').filter(Boolean);
|
|
138
|
-
const path = segments.map((segment)=>{
|
|
139
|
-
if (segment.startsWith(':')) {
|
|
140
|
-
const paramName = getParamName(segment);
|
|
141
|
-
const param = Object.hasOwn(params, paramName) ? params[paramName] : void 0;
|
|
142
|
-
if (void 0 === param || '' === param) {
|
|
143
|
-
if (segment.endsWith('?')) return '';
|
|
144
|
-
throw new Error(`Missing required path parameter "${paramName}" for pattern "${normalisePathPattern(pattern)}".`);
|
|
145
|
-
}
|
|
146
|
-
return encodeURIComponent(param);
|
|
147
|
-
}
|
|
148
|
-
if ('*' === segment) return encodeSplatParam(params['*'] || '');
|
|
149
|
-
return segment;
|
|
150
|
-
}).filter(Boolean).join('/');
|
|
151
|
-
return `/${path}`;
|
|
152
|
-
};
|
|
153
|
-
export { buildPathFromPattern, doPathPatternsOverlap, getOrderedPathParamSignature, getPathParamSignature, getPathPatternValidationIssue, getPhysicalPathPattern, haveEqualPatternSpecificity, matchPathPattern, sortPatternsBySpecificity };
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
import { normalisePathname } from "./normalise.mjs";
|
|
3
|
-
import { stripLanguagePrefix } from "./pathname.mjs";
|
|
4
|
-
const DEFAULT_LOCALE_REDIRECT_SKIP_RULES = [
|
|
5
|
-
{
|
|
6
|
-
type: 'exact',
|
|
7
|
-
path: '/backend-mf-manifest.json'
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
type: 'exact',
|
|
11
|
-
path: '/backendRemoteEntry.cjs'
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
type: 'exact',
|
|
15
|
-
path: '/mf-manifest.json'
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
type: 'exact',
|
|
19
|
-
path: '/mf-stats.json'
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
type: 'exact',
|
|
23
|
-
path: '/remoteEntry.js'
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
type: 'prefix',
|
|
27
|
-
path: '/static/'
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
type: 'prefix',
|
|
31
|
-
path: '/upload/'
|
|
32
|
-
}
|
|
33
|
-
];
|
|
34
|
-
const stripTrailingSlash = (pathname)=>pathname.length > 1 ? pathname.replace(/\/+$/, '') : pathname;
|
|
35
|
-
const matchesPathPrefix = (pathname, prefix)=>{
|
|
36
|
-
const normalizedPathname = normalisePathname(pathname);
|
|
37
|
-
const normalizedPrefix = stripTrailingSlash(normalisePathname(prefix));
|
|
38
|
-
return normalizedPathname === normalizedPrefix || normalizedPathname.startsWith(`${normalizedPrefix}/`);
|
|
39
|
-
};
|
|
40
|
-
const matchesSkipRule = (pathname, rule)=>{
|
|
41
|
-
if ('exact' === rule.type) return normalisePathname(pathname) === normalisePathname(rule.path);
|
|
42
|
-
return matchesPathPrefix(pathname, rule.path);
|
|
43
|
-
};
|
|
44
|
-
const isDefaultLocaleRedirectSkipPath = (pathname, languages = [])=>{
|
|
45
|
-
const normalizedPathname = normalisePathname(pathname);
|
|
46
|
-
const pathWithoutLanguage = stripLanguagePrefix(normalizedPathname, languages);
|
|
47
|
-
return DEFAULT_LOCALE_REDIRECT_SKIP_RULES.some((rule)=>matchesSkipRule(pathWithoutLanguage, rule));
|
|
48
|
-
};
|
|
49
|
-
const shouldSkipLocaleRedirect = (pathname, languages = [], ignoreRedirectRoutes)=>{
|
|
50
|
-
const normalizedPathname = normalisePathname(pathname);
|
|
51
|
-
const pathWithoutLanguage = stripLanguagePrefix(normalizedPathname, languages);
|
|
52
|
-
if (isDefaultLocaleRedirectSkipPath(pathWithoutLanguage)) return true;
|
|
53
|
-
if (!ignoreRedirectRoutes) return false;
|
|
54
|
-
if ('function' == typeof ignoreRedirectRoutes) return ignoreRedirectRoutes(pathWithoutLanguage);
|
|
55
|
-
return ignoreRedirectRoutes.some((pattern)=>matchesPathPrefix(pathWithoutLanguage, pattern));
|
|
56
|
-
};
|
|
57
|
-
export { DEFAULT_LOCALE_REDIRECT_SKIP_RULES, isDefaultLocaleRedirectSkipPath, matchesPathPrefix, shouldSkipLocaleRedirect };
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
import { normalisePathname } from "./normalise.mjs";
|
|
3
|
-
import { buildPathFromPattern, matchPathPattern, sortPatternsBySpecificity } from "./patterns.mjs";
|
|
4
|
-
const getCanonicalCandidates = (localisedUrls)=>sortPatternsBySpecificity(Object.entries(localisedUrls).map(([canonicalPattern, localisedUrlEntry])=>({
|
|
5
|
-
pattern: canonicalPattern,
|
|
6
|
-
canonicalPattern,
|
|
7
|
-
localisedUrlEntry
|
|
8
|
-
})));
|
|
9
|
-
const resolveLocalisedUrlPath = (pathname, languages, localisedUrls, options)=>{
|
|
10
|
-
const normalizedPathname = normalisePathname(pathname);
|
|
11
|
-
const canonicalCandidates = getCanonicalCandidates(localisedUrls);
|
|
12
|
-
const candidates = sortPatternsBySpecificity(canonicalCandidates.flatMap(({ canonicalPattern, localisedUrlEntry })=>{
|
|
13
|
-
const targetPattern = 'localised' === options.mode ? localisedUrlEntry[options.targetLanguage] : canonicalPattern;
|
|
14
|
-
if (!targetPattern) return [];
|
|
15
|
-
const sourcePatterns = new Set([
|
|
16
|
-
canonicalPattern,
|
|
17
|
-
...languages.map((language)=>localisedUrlEntry[language]).filter((sourcePattern)=>Boolean(sourcePattern))
|
|
18
|
-
]);
|
|
19
|
-
return Array.from(sourcePatterns, (sourcePattern)=>({
|
|
20
|
-
pattern: sourcePattern,
|
|
21
|
-
sourcePattern,
|
|
22
|
-
targetPattern
|
|
23
|
-
}));
|
|
24
|
-
}));
|
|
25
|
-
for (const { sourcePattern, targetPattern } of candidates){
|
|
26
|
-
const params = matchPathPattern(normalizedPathname, sourcePattern);
|
|
27
|
-
if (params) return buildPathFromPattern(targetPattern, params);
|
|
28
|
-
}
|
|
29
|
-
return normalizedPathname;
|
|
30
|
-
};
|
|
31
|
-
const resolveLocalisedPath = (pathname, targetLanguage, languages, localisedUrls)=>resolveLocalisedUrlPath(pathname, languages, localisedUrls, {
|
|
32
|
-
mode: 'localised',
|
|
33
|
-
targetLanguage
|
|
34
|
-
});
|
|
35
|
-
const resolveCanonicalLocalisedPath = (pathname, languages, localisedUrls)=>resolveLocalisedUrlPath(pathname, languages, localisedUrls, {
|
|
36
|
-
mode: 'canonical'
|
|
37
|
-
});
|
|
38
|
-
export { resolveCanonicalLocalisedPath, resolveLocalisedPath };
|