next-intl 3.15.5 → 3.15.6-canary.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/development/middleware/getAlternateLinksHeaderValue.js +2 -0
- package/dist/development/middleware/middleware.js +1 -1
- package/dist/development/middleware/utils.js +13 -14
- package/dist/development/plugin.js +29 -25
- package/dist/development/shared/utils.js +26 -2
- package/dist/esm/middleware/getAlternateLinksHeaderValue.js +1 -1
- package/dist/esm/middleware/middleware.js +1 -1
- package/dist/esm/middleware/utils.js +1 -1
- package/dist/esm/plugin.js +1 -1
- package/dist/esm/shared/utils.js +1 -1
- package/dist/production/middleware/getAlternateLinksHeaderValue.js +1 -1
- package/dist/production/middleware/middleware.js +1 -1
- package/dist/production/middleware/utils.js +1 -1
- package/dist/production/plugin.js +1 -1
- package/dist/production/shared/utils.js +1 -1
- package/dist/types/src/middleware/utils.d.ts +0 -1
- package/dist/types/src/shared/utils.d.ts +1 -0
- package/package.json +6 -6
- /package/dist/types/{test → src}/middleware/getAlternateLinksHeaderValue.test.d.ts +0 -0
- /package/dist/types/{test → src}/middleware/middleware.test.d.ts +0 -0
- /package/dist/types/{test → src}/middleware/resolveLocale.test.d.ts +0 -0
- /package/dist/types/{test → src}/middleware/utils.test.d.ts +0 -0
- /package/dist/types/{test → src}/navigation/createLocalizedPathnamesNavigation.test.d.ts +0 -0
- /package/dist/types/{test → src}/navigation/createSharedPathnamesNavigation.test.d.ts +0 -0
- /package/dist/types/{test → src}/navigation/react-client/ClientLink.test.d.ts +0 -0
- /package/dist/types/{test → src}/navigation/react-client/createLocalizedPathnamesNavigation.test.d.ts +0 -0
- /package/dist/types/{test → src}/navigation/react-client/createSharedPathnamesNavigation.test.d.ts +0 -0
- /package/dist/types/{test → src}/navigation/react-client/useBasePathname.test.d.ts +0 -0
- /package/dist/types/{test → src}/navigation/react-client/useBaseRouter.test.d.ts +0 -0
- /package/dist/types/{test → src}/navigation/shared/redirects.test.d.ts +0 -0
- /package/dist/types/{test → src}/navigation/shared/utils.test.d.ts +0 -0
- /package/dist/types/{test → src}/react-client/useFormatter.test.d.ts +0 -0
- /package/dist/types/{test → src}/react-client/useLocale.test.d.ts +0 -0
- /package/dist/types/{test → src}/react-client/useNow.test.d.ts +0 -0
- /package/dist/types/{test → src}/react-client/useTimeZone.test.d.ts +0 -0
- /package/dist/types/{test → src}/react-client/useTranslations.test.d.ts +0 -0
- /package/dist/types/{test → src}/react-server/NextIntlClientProviderServer.test.d.ts +0 -0
- /package/dist/types/{test → src}/react-server/index.test.d.ts +0 -0
- /package/dist/types/{test → src}/react-server/useTranslations.test.d.ts +0 -0
- /package/dist/types/{test → src}/react-server/utils.d.ts +0 -0
- /package/dist/types/{test → src}/routing/types.test.d.ts +0 -0
- /package/dist/types/{test → src}/server/react-client/index.test.d.ts +0 -0
- /package/dist/types/{test → src}/server/react-server/index.test.d.ts +0 -0
- /package/dist/types/{test → src}/shared/NextIntlClientProvider.test.d.ts +0 -0
- /package/dist/types/{test → src}/shared/utils.test.d.ts +0 -0
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var utils$1 = require('../shared/utils.js');
|
|
5
6
|
var utils = require('./utils.js');
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -24,6 +25,7 @@ function getAlternateLinksHeaderValue(_ref) {
|
|
|
24
25
|
normalizedUrl.protocol = (_request$headers$get = request.headers.get('x-forwarded-proto')) !== null && _request$headers$get !== void 0 ? _request$headers$get : normalizedUrl.protocol;
|
|
25
26
|
normalizedUrl.pathname = utils.getNormalizedPathname(normalizedUrl.pathname, config.locales, config.localePrefix);
|
|
26
27
|
function getAlternateEntry(url, locale) {
|
|
28
|
+
url.pathname = utils$1.normalizeTrailingSlash(url.pathname);
|
|
27
29
|
if (request.nextUrl.basePath) {
|
|
28
30
|
url = new URL(url);
|
|
29
31
|
url.pathname = utils.applyBasePath(url.pathname, request.nextUrl.basePath);
|
|
@@ -38,7 +38,7 @@ function createMiddleware(input) {
|
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
function redirect(url, redirectDomain) {
|
|
41
|
-
const urlObj = new URL(utils.normalizeTrailingSlash(url), request.url);
|
|
41
|
+
const urlObj = new URL(utils$1.normalizeTrailingSlash(url), request.url);
|
|
42
42
|
if (domainsConfig.length > 0 && !redirectDomain) {
|
|
43
43
|
const bestMatchingDomain = utils.getBestMatchingDomain(domain, locale, domainsConfig);
|
|
44
44
|
if (bestMatchingDomain) {
|
|
@@ -49,7 +49,11 @@ function formatTemplatePathname(sourcePathname, sourceTemplate, targetTemplate,
|
|
|
49
49
|
const params = getRouteParams(sourceTemplate, sourcePathname);
|
|
50
50
|
let targetPathname = '';
|
|
51
51
|
targetPathname += formatPathnameTemplate(targetTemplate, params);
|
|
52
|
-
|
|
52
|
+
|
|
53
|
+
// A pathname with an optional catchall like `/categories/[[...slug]]`
|
|
54
|
+
// should be normalized to `/categories` if the catchall is not present
|
|
55
|
+
// and no trailing slash is configured
|
|
56
|
+
targetPathname = utils.normalizeTrailingSlash(targetPathname);
|
|
53
57
|
return targetPathname;
|
|
54
58
|
}
|
|
55
59
|
|
|
@@ -70,7 +74,7 @@ function getNormalizedPathname(pathname, locales, localePrefix) {
|
|
|
70
74
|
const match = pathname.match(regex);
|
|
71
75
|
let result = match ? '/' + match[2] : pathname;
|
|
72
76
|
if (result !== '/') {
|
|
73
|
-
result = normalizeTrailingSlash(result);
|
|
77
|
+
result = utils.normalizeTrailingSlash(result);
|
|
74
78
|
}
|
|
75
79
|
return result;
|
|
76
80
|
}
|
|
@@ -102,13 +106,15 @@ function getPathnameMatch(pathname, locales, localePrefix) {
|
|
|
102
106
|
}
|
|
103
107
|
}
|
|
104
108
|
function getRouteParams(template, pathname) {
|
|
105
|
-
const
|
|
106
|
-
const
|
|
109
|
+
const normalizedPathname = utils.normalizeTrailingSlash(pathname);
|
|
110
|
+
const normalizedTemplate = utils.normalizeTrailingSlash(template);
|
|
111
|
+
const regex = utils.templateToRegex(normalizedTemplate);
|
|
112
|
+
const match = regex.exec(normalizedPathname);
|
|
107
113
|
if (!match) return undefined;
|
|
108
114
|
const params = {};
|
|
109
115
|
for (let i = 1; i < match.length; i++) {
|
|
110
|
-
var
|
|
111
|
-
const key = (
|
|
116
|
+
var _normalizedTemplate$m;
|
|
117
|
+
const key = (_normalizedTemplate$m = normalizedTemplate.match(/\[([^\]]+)\]/g)) === null || _normalizedTemplate$m === void 0 ? void 0 : _normalizedTemplate$m[i - 1].replace(/[[\]]/g, '');
|
|
112
118
|
if (key) params[key] = match[i];
|
|
113
119
|
}
|
|
114
120
|
return params;
|
|
@@ -173,13 +179,7 @@ function getBestMatchingDomain(curHostDomain, locale, domainsConfig) {
|
|
|
173
179
|
return domainConfig;
|
|
174
180
|
}
|
|
175
181
|
function applyBasePath(pathname, basePath) {
|
|
176
|
-
return normalizeTrailingSlash(basePath + pathname);
|
|
177
|
-
}
|
|
178
|
-
function normalizeTrailingSlash(pathname) {
|
|
179
|
-
if (pathname !== '/' && pathname.endsWith('/')) {
|
|
180
|
-
pathname = pathname.slice(0, -1);
|
|
181
|
-
}
|
|
182
|
-
return pathname;
|
|
182
|
+
return utils.normalizeTrailingSlash(basePath + pathname);
|
|
183
183
|
}
|
|
184
184
|
function getLocaleAsPrefix(locale) {
|
|
185
185
|
return "/".concat(locale);
|
|
@@ -198,4 +198,3 @@ exports.getNormalizedPathname = getNormalizedPathname;
|
|
|
198
198
|
exports.getPathnameMatch = getPathnameMatch;
|
|
199
199
|
exports.getRouteParams = getRouteParams;
|
|
200
200
|
exports.isLocaleSupportedOnDomain = isLocaleSupportedOnDomain;
|
|
201
|
-
exports.normalizeTrailingSlash = normalizeTrailingSlash;
|
|
@@ -36,45 +36,49 @@ function resolveI18nPath(providedPath, cwd) {
|
|
|
36
36
|
}
|
|
37
37
|
function initPlugin(i18nPath, nextConfig) {
|
|
38
38
|
if ((nextConfig === null || nextConfig === void 0 ? void 0 : nextConfig.i18n) != null) {
|
|
39
|
-
console.warn("\nnext-intl has found an `i18n` config in your next.config.js. This likely causes conflicts and should therefore be removed if you use the App Router.\n\nIf you're in progress of migrating from the `pages` folder, you can refer to this example: https://
|
|
39
|
+
console.warn("\nnext-intl has found an `i18n` config in your next.config.js. This likely causes conflicts and should therefore be removed if you use the App Router.\n\nIf you're in progress of migrating from the `pages` folder, you can refer to this example: https://next-intl-docs.vercel.app/examples#app-router-migration\n");
|
|
40
40
|
}
|
|
41
41
|
const useTurbo = process.env.TURBOPACK != null;
|
|
42
|
-
|
|
42
|
+
const nextIntlConfig = {};
|
|
43
|
+
|
|
44
|
+
// Assign alias for `next-intl/config`
|
|
43
45
|
if (useTurbo) {
|
|
44
46
|
var _nextConfig$experimen, _nextConfig$experimen2;
|
|
45
47
|
if (i18nPath && i18nPath.startsWith('/')) {
|
|
46
48
|
throw new Error("Turbopack support for next-intl currently does not support absolute paths, please provide a relative one (e.g. './src/i18n/config.ts').\n\nFound: " + i18nPath + '\n');
|
|
47
49
|
}
|
|
48
|
-
nextIntlConfig = {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
'next-intl/config': resolveI18nPath(i18nPath)
|
|
58
|
-
}
|
|
50
|
+
nextIntlConfig.experimental = {
|
|
51
|
+
...(nextConfig === null || nextConfig === void 0 ? void 0 : nextConfig.experimental),
|
|
52
|
+
turbo: {
|
|
53
|
+
...(nextConfig === null || nextConfig === void 0 || (_nextConfig$experimen = nextConfig.experimental) === null || _nextConfig$experimen === void 0 ? void 0 : _nextConfig$experimen.turbo),
|
|
54
|
+
resolveAlias: {
|
|
55
|
+
...(nextConfig === null || nextConfig === void 0 || (_nextConfig$experimen2 = nextConfig.experimental) === null || _nextConfig$experimen2 === void 0 || (_nextConfig$experimen2 = _nextConfig$experimen2.turbo) === null || _nextConfig$experimen2 === void 0 ? void 0 : _nextConfig$experimen2.resolveAlias),
|
|
56
|
+
// Turbo aliases don't work with absolute
|
|
57
|
+
// paths (see error handling above)
|
|
58
|
+
'next-intl/config': resolveI18nPath(i18nPath)
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
62
|
} else {
|
|
63
|
-
nextIntlConfig = {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
_ref[_key] = arguments[_key];
|
|
67
|
-
}
|
|
68
|
-
let [config, options] = _ref;
|
|
69
|
-
// Webpack requires absolute paths
|
|
70
|
-
config.resolve.alias['next-intl/config'] = path__default.default.resolve(config.context, resolveI18nPath(i18nPath, config.context));
|
|
71
|
-
if (typeof (nextConfig === null || nextConfig === void 0 ? void 0 : nextConfig.webpack) === 'function') {
|
|
72
|
-
return nextConfig.webpack(config, options);
|
|
73
|
-
}
|
|
74
|
-
return config;
|
|
63
|
+
nextIntlConfig.webpack = function webpack() {
|
|
64
|
+
for (var _len = arguments.length, _ref = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
65
|
+
_ref[_key] = arguments[_key];
|
|
75
66
|
}
|
|
67
|
+
let [config, options] = _ref;
|
|
68
|
+
// Webpack requires absolute paths
|
|
69
|
+
config.resolve.alias['next-intl/config'] = path__default.default.resolve(config.context, resolveI18nPath(i18nPath, config.context));
|
|
70
|
+
if (typeof (nextConfig === null || nextConfig === void 0 ? void 0 : nextConfig.webpack) === 'function') {
|
|
71
|
+
return nextConfig.webpack(config, options);
|
|
72
|
+
}
|
|
73
|
+
return config;
|
|
76
74
|
};
|
|
77
75
|
}
|
|
76
|
+
|
|
77
|
+
// Forward config
|
|
78
|
+
nextIntlConfig.env = {
|
|
79
|
+
...(nextConfig === null || nextConfig === void 0 ? void 0 : nextConfig.env),
|
|
80
|
+
_next_intl_trailing_slash: nextConfig !== null && nextConfig !== void 0 && nextConfig.trailingSlash ? 'true' : undefined
|
|
81
|
+
};
|
|
78
82
|
return Object.assign({}, nextConfig, nextIntlConfig);
|
|
79
83
|
}
|
|
80
84
|
module.exports = function createNextIntlPlugin(i18nPath) {
|
|
@@ -62,11 +62,33 @@ function prefixPathname(prefix, pathname) {
|
|
|
62
62
|
function hasPathnamePrefixed(prefix, pathname) {
|
|
63
63
|
return pathname === prefix || pathname.startsWith("".concat(prefix, "/"));
|
|
64
64
|
}
|
|
65
|
+
function hasTrailingSlash() {
|
|
66
|
+
try {
|
|
67
|
+
// Provided via `env` setting in `next.config.js` via the plugin
|
|
68
|
+
return process.env._next_intl_trailing_slash === 'true';
|
|
69
|
+
} catch (e) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function normalizeTrailingSlash(pathname) {
|
|
74
|
+
const trailingSlash = hasTrailingSlash();
|
|
75
|
+
if (pathname !== '/') {
|
|
76
|
+
const pathnameEndsWithSlash = pathname.endsWith('/');
|
|
77
|
+
if (trailingSlash && !pathnameEndsWithSlash) {
|
|
78
|
+
pathname += '/';
|
|
79
|
+
} else if (!trailingSlash && pathnameEndsWithSlash) {
|
|
80
|
+
pathname = pathname.slice(0, -1);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return pathname;
|
|
84
|
+
}
|
|
65
85
|
function matchesPathname( /** E.g. `/users/[userId]-[userName]` */
|
|
66
86
|
template, /** E.g. `/users/23-jane` */
|
|
67
87
|
pathname) {
|
|
68
|
-
const
|
|
69
|
-
|
|
88
|
+
const normalizedTemplate = normalizeTrailingSlash(template);
|
|
89
|
+
const normalizedPathname = normalizeTrailingSlash(pathname);
|
|
90
|
+
const regex = templateToRegex(normalizedTemplate);
|
|
91
|
+
return regex.test(normalizedPathname);
|
|
70
92
|
}
|
|
71
93
|
function getLocalePrefix(locale, localePrefix) {
|
|
72
94
|
var _localePrefix$prefixe;
|
|
@@ -105,6 +127,7 @@ function comparePathnamePairs(a, b) {
|
|
|
105
127
|
// If one of the paths ends, prioritize the shorter path
|
|
106
128
|
if (!segmentA && segmentB) return -1;
|
|
107
129
|
if (segmentA && !segmentB) return 1;
|
|
130
|
+
if (!segmentA && !segmentB) continue;
|
|
108
131
|
|
|
109
132
|
// Prioritize static segments over dynamic segments
|
|
110
133
|
if (!isDynamicSegment(segmentA) && isDynamicSegment(segmentB)) return -1;
|
|
@@ -137,6 +160,7 @@ exports.hasPathnamePrefixed = hasPathnamePrefixed;
|
|
|
137
160
|
exports.isLocalizableHref = isLocalizableHref;
|
|
138
161
|
exports.localizeHref = localizeHref;
|
|
139
162
|
exports.matchesPathname = matchesPathname;
|
|
163
|
+
exports.normalizeTrailingSlash = normalizeTrailingSlash;
|
|
140
164
|
exports.prefixHref = prefixHref;
|
|
141
165
|
exports.prefixPathname = prefixPathname;
|
|
142
166
|
exports.templateToRegex = templateToRegex;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getHost as
|
|
1
|
+
import{normalizeTrailingSlash as e}from"../shared/utils.js";import{getHost as a,getNormalizedPathname as t,getLocalePrefixes as o,isLocaleSupportedOnDomain as n,applyBasePath as l,formatTemplatePathname as r}from"./utils.js";function c(c){var m;let{config:p,localizedPathnames:s,request:f,resolvedLocale:i}=c;const h=f.nextUrl.clone(),d=a(f.headers);function u(a,t){return a.pathname=e(a.pathname),f.nextUrl.basePath&&((a=new URL(a)).pathname=l(a.pathname,f.nextUrl.basePath)),"<".concat(a.toString(),'>; rel="alternate"; hreflang="').concat(t,'"')}function x(e,a){return s&&"object"==typeof s?r(e,s[i],s[a]):e}d&&(h.port="",h.host=d),h.protocol=null!==(m=f.headers.get("x-forwarded-proto"))&&void 0!==m?m:h.protocol,h.pathname=t(h.pathname,p.locales,p.localePrefix);const w=o(p.locales,p.localePrefix).flatMap((e=>{let a,[t,o]=e;function l(e){return"/"===e?o:o+e}if(p.domains){return(p.domains.filter((e=>n(t,e)))||[]).map((e=>(a=new URL(h),a.port="",a.host=e.domain,a.pathname=x(h.pathname,t),t===e.defaultLocale&&"always"!==p.localePrefix.mode||(a.pathname=l(a.pathname)),u(a,t))))}{let e;e=s&&"object"==typeof s?x(h.pathname,t):h.pathname,t===p.defaultLocale&&"always"!==p.localePrefix.mode||(e=l(e)),a=new URL(e,h)}return u(a,t)}));if(!p.domains&&("always"!==p.localePrefix.mode||"/"===h.pathname)){const e=new URL(x(h.pathname,p.defaultLocale),h);w.push(u(e,"x-default"))}return w.join(", ")}export{c as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{NextResponse as e}from"next/server";import{HEADER_LOCALE_NAME as o}from"../shared/constants.js";import{matchesPathname as l,getLocalePrefix as
|
|
1
|
+
import{NextResponse as e}from"next/server";import{HEADER_LOCALE_NAME as o}from"../shared/constants.js";import{matchesPathname as l,normalizeTrailingSlash as r,getLocalePrefix as t}from"../shared/utils.js";import{receiveConfig as a}from"./config.js";import n from"./getAlternateLinksHeaderValue.js";import s from"./resolveLocale.js";import i from"./syncCookie.js";import{isLocaleSupportedOnDomain as c,getNormalizedPathname as d,getPathnameMatch as f,getInternalTemplate as m,formatTemplatePathname as h,formatPathname as x,getBestMatchingDomain as u,applyBasePath as p,getLocaleAsPrefix as v}from"./utils.js";function U(U){const P=a(U);return function(a){var U;const g=decodeURI(a.nextUrl.pathname),{domain:L,locale:j}=s(P,a.headers,a.cookies,g),w=L?L.defaultLocale===j:j===P.defaultLocale,k=(null===(U=P.domains)||void 0===U?void 0:U.filter((e=>c(j,e))))||[],b=null!=P.domains&&!L;function y(l){const r=new URL(l,a.url);a.nextUrl.basePath&&(r.pathname=p(r.pathname,a.nextUrl.basePath));const t=new Headers(a.headers);return t.set(o,j),e.rewrite(r,{request:{headers:t}})}function R(o,l){const t=new URL(r(o),a.url);if(k.length>0&&!l){const e=u(L,j,k);e&&(l=e.domain,e.defaultLocale===j&&"as-needed"===P.localePrefix.mode&&(t.pathname=d(t.pathname,P.locales,P.localePrefix)))}var n,s;l&&(t.host=l,a.headers.get("x-forwarded-host")&&(t.protocol=null!==(n=a.headers.get("x-forwarded-proto"))&&void 0!==n?n:a.nextUrl.protocol,t.port=null!==(s=a.headers.get("x-forwarded-port"))&&void 0!==s?s:""));return a.nextUrl.basePath&&(t.pathname=p(t.pathname,a.nextUrl.basePath)),e.redirect(t.toString())}const q=d(g,P.locales,P.localePrefix),H=f(g,P.locales,P.localePrefix),z=null!=H,A="never"===P.localePrefix.mode||w&&"as-needed"===P.localePrefix.mode;let C,D,I=q;if(P.pathnames){let e;if([e,D]=m(P.pathnames,q,j),D){const o=P.pathnames[D],r="string"==typeof o?o:o[j];if(l(r,q))I=h(q,r,D);else{let l;l=e?"string"==typeof o?o:o[e]:D;const n=A?void 0:t(j,P.localePrefix),s=h(q,l,r);C=R(x(s,n,a.nextUrl.search))}}}if(!C)if("/"!==I||z){const e=x(I,v(j),a.nextUrl.search);if(z){const o=x(q,H.prefix,a.nextUrl.search);if("never"===P.localePrefix.mode)C=R(x(q,void 0,a.nextUrl.search));else if(H.exact)if(w&&A)C=R(x(q,void 0,a.nextUrl.search));else if(P.domains){const l=u(L,H.locale,k);C=(null==L?void 0:L.domain)===(null==l?void 0:l.domain)||b?y(e):R(o,null==l?void 0:l.domain)}else C=y(e);else C=R(o)}else C=A?y(e):R(x(q,t(j,P.localePrefix),a.nextUrl.search))}else C=A?y(x(I,v(j),a.nextUrl.search)):R(x(q,t(j,P.localePrefix),a.nextUrl.search));var S;(P.localeDetection&&i(a,C,j),"never"!==P.localePrefix.mode&&P.alternateLinks&&P.locales.length>1)&&C.headers.set("Link",n({config:P,localizedPathnames:null!=D?null===(S=P.pathnames)||void 0===S?void 0:S[D]:void 0,request:a,resolvedLocale:j}));return C}}export{U as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getSortedPathnames as t,matchesPathname as e,
|
|
1
|
+
import{getSortedPathnames as t,matchesPathname as e,normalizeTrailingSlash as n,getLocalePrefix as o,templateToRegex as r,prefixPathname as c}from"../shared/utils.js";function l(n,o,r){const c=t(Object.keys(n));for(const t of c){const c=n[t];if("string"==typeof c){if(e(c,o))return[void 0,t]}else{const n=Object.entries(c),l=n.findIndex((t=>{let[e]=t;return e===r}));l>0&&n.unshift(n.splice(l,1)[0]);for(const[r,c]of n)if(e(c,o))return[r,t]}}for(const t of Object.keys(n))if(e(t,o))return[void 0,t];return[void 0,void 0]}function i(t,e,o,r){let c="";return c+=d(o,a(e,t)),c=n(c),c}function u(t,e,o){t.endsWith("/")||(t+="/");const r=f(e,o),c=new RegExp("^(".concat(r.map((t=>{let[,e]=t;return e.replaceAll("/","\\/")})).join("|"),")/(.*)"),"i"),l=t.match(c);let i=l?"/"+l[2]:t;return"/"!==i&&(i=n(i)),i}function f(t,e){return t.map((t=>[t,o(t,e)]))}function s(t,e,n){const o=f(e,n);for(const[e,n]of o){let o,r;if(t===n||t.startsWith(n+"/"))o=r=!0;else{const e=t.toLowerCase(),c=n.toLowerCase();(e===c||e.startsWith(c+"/"))&&(o=!1,r=!0)}if(r)return{locale:e,prefix:n,matchedPrefix:t.slice(0,n.length),exact:o}}}function a(t,e){const o=n(e),c=n(t),l=r(c).exec(o);if(!l)return;const i={};for(let t=1;t<l.length;t++){var u;const e=null===(u=c.match(/\[([^\]]+)\]/g))||void 0===u?void 0:u[t-1].replace(/[[\]]/g,"");e&&(i[e]=l[t])}return i}function d(t,e){if(!e)return t;let n=t=t.replace(/\[\[/g,"[").replace(/\]\]/g,"]");return Object.entries(e).forEach((t=>{let[e,o]=t;n=n.replace("[".concat(e,"]"),o)})),n}function h(t,e,n){let o=t;return e&&(o=c(e,o)),n&&(o+=n),o}function p(t){var e,n;return null!==(e=null!==(n=t.get("x-forwarded-host"))&&void 0!==n?n:t.get("host"))&&void 0!==e?e:void 0}function v(t,e){return e.defaultLocale===t||!e.locales||e.locales.includes(t)}function g(t,e,n){let o;return t&&v(e,t)&&(o=t),o||(o=n.find((t=>t.defaultLocale===e))),o||(o=n.find((t=>null!=t.locales&&t.locales.includes(e)))),o||null!=(null==t?void 0:t.locales)||(o=t),o||(o=n.find((t=>!t.locales))),o}function x(t,e){return n(e+t)}function m(t){return"/".concat(t)}export{x as applyBasePath,h as formatPathname,d as formatPathnameTemplate,i as formatTemplatePathname,g as getBestMatchingDomain,p as getHost,l as getInternalTemplate,m as getLocaleAsPrefix,f as getLocalePrefixes,u as getNormalizedPathname,s as getPathnameMatch,a as getRouteParams,v as isLocaleSupportedOnDomain};
|
package/dist/esm/plugin.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import n from"fs";import e from"path";function t(t,o){function r(t){return n.existsSync(function(n){const t=[];return o&&t.push(o),t.push(n),e.resolve(...t)}(t))}if(t){if(!r(t))throw new Error("Could not find i18n config at ".concat(t,", please provide a valid path."));return t}for(const n of["./i18n.tsx","./i18n.ts","./i18n.js","./i18n.jsx","./src/i18n.tsx","./src/i18n.ts","./src/i18n.js","./src/i18n.jsx"])if(r(n))return n;throw new Error("\n\nCould not locate i18n config. Create one at `./(src/)i18n.{js,jsx,ts,tsx}` or specify a custom location:\n\nconst withNextIntl = require('next-intl/plugin')(\n './path/to/i18n.tsx'\n);\n\nmodule.exports = withNextIntl({\n // Other Next.js configuration ...\n});\n")}module.exports=function(n){return function(o){return function(n,o){
|
|
1
|
+
import n from"fs";import e from"path";function t(t,o){function r(t){return n.existsSync(function(n){const t=[];return o&&t.push(o),t.push(n),e.resolve(...t)}(t))}if(t){if(!r(t))throw new Error("Could not find i18n config at ".concat(t,", please provide a valid path."));return t}for(const n of["./i18n.tsx","./i18n.ts","./i18n.js","./i18n.jsx","./src/i18n.tsx","./src/i18n.ts","./src/i18n.js","./src/i18n.jsx"])if(r(n))return n;throw new Error("\n\nCould not locate i18n config. Create one at `./(src/)i18n.{js,jsx,ts,tsx}` or specify a custom location:\n\nconst withNextIntl = require('next-intl/plugin')(\n './path/to/i18n.tsx'\n);\n\nmodule.exports = withNextIntl({\n // Other Next.js configuration ...\n});\n")}module.exports=function(n){return function(o){return function(n,o){null!=(null==o?void 0:o.i18n)&&console.warn("\nnext-intl has found an `i18n` config in your next.config.js. This likely causes conflicts and should therefore be removed if you use the App Router.\n\nIf you're in progress of migrating from the `pages` folder, you can refer to this example: https://next-intl-docs.vercel.app/examples#app-router-migration\n");const r={};if(null!=process.env.TURBOPACK){var i,s;if(n&&n.startsWith("/"))throw new Error("Turbopack support for next-intl currently does not support absolute paths, please provide a relative one (e.g. './src/i18n/config.ts').\n\nFound: "+n+"\n");r.experimental={...null==o?void 0:o.experimental,turbo:{...null==o||null===(i=o.experimental)||void 0===i?void 0:i.turbo,resolveAlias:{...null==o||null===(s=o.experimental)||void 0===s||null===(s=s.turbo)||void 0===s?void 0:s.resolveAlias,"next-intl/config":t(n)}}}}else r.webpack=function(){for(var r=arguments.length,i=new Array(r),s=0;s<r;s++)i[s]=arguments[s];let[l,u]=i;return l.resolve.alias["next-intl/config"]=e.resolve(l.context,t(n,l.context)),"function"==typeof(null==o?void 0:o.webpack)?o.webpack(l,u):l};return r.env={...null==o?void 0:o.env,_next_intl_trailing_slash:null!=o&&o.trailingSlash?"true":void 0},Object.assign({},o,r)}(n,o)}};
|
package/dist/esm/shared/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function n(n){return function(n){return"object"==typeof n?null==n.host&&null==n.hostname:!/^[a-z]+:/i.test(n)}(n)&&!function(n){const t="object"==typeof n?n.pathname:n;return null!=t&&!t.startsWith("/")}(n)}function t(t,r){let u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:r,
|
|
1
|
+
function n(n){return function(n){return"object"==typeof n?null==n.host&&null==n.hostname:!/^[a-z]+:/i.test(n)}(n)&&!function(n){const t="object"==typeof n?n.pathname:n;return null!=t&&!t.startsWith("/")}(n)}function t(t,r){let u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:r,c=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0;if(!n(t))return t;const f=r!==u,l=i(o,c);return(f||l)&&null!=o?e(t,o):t}function e(n,t){let e;return"string"==typeof n?e=u(t,n):(e={...n},n.pathname&&(e.pathname=u(t,n.pathname))),e}function r(n,t){return n.replace(new RegExp("^".concat(t)),"")||"/"}function u(n,t){let e=n;return/^\/(\?.*)?$/.test(t)&&(t=t.slice(1)),e+=t,e}function i(n,t){return t===n||t.startsWith("".concat(n,"/"))}function c(n){const t=function(){try{return"true"===process.env._next_intl_trailing_slash}catch(n){return!1}}();if("/"!==n){const e=n.endsWith("/");t&&!e?n+="/":!t&&e&&(n=n.slice(0,-1))}return n}function o(n,t){const e=c(n),r=c(t);return l(e).test(r)}function f(n,t){var e;return"never"!==t.mode&&(null===(e=t.prefixes)||void 0===e?void 0:e[n])||"/"+n}function l(n){const t=n.replace(/\[\[(\.\.\.[^\]]+)\]\]/g,"?(.*)").replace(/\[(\.\.\.[^\]]+)\]/g,"(.+)").replace(/\[([^\]]+)\]/g,"([^/]+)");return new RegExp("^".concat(t,"$"))}function s(n){return n.includes("[[...")}function a(n){return n.includes("[...")}function p(n){return n.includes("[")}function h(n,t){const e=n.split("/"),r=t.split("/"),u=Math.max(e.length,r.length);for(let n=0;n<u;n++){const t=e[n],u=r[n];if(!t&&u)return-1;if(t&&!u)return 1;if(t||u){if(!p(t)&&p(u))return-1;if(p(t)&&!p(u))return 1;if(!a(t)&&a(u))return-1;if(a(t)&&!a(u))return 1;if(!s(t)&&s(u))return-1;if(s(t)&&!s(u))return 1}}return 0}function g(n){return n.sort(h)}export{f as getLocalePrefix,g as getSortedPathnames,i as hasPathnamePrefixed,n as isLocalizableHref,t as localizeHref,o as matchesPathname,c as normalizeTrailingSlash,e as prefixHref,u as prefixPathname,l as templateToRegex,r as unprefixPathname};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./utils.js");exports.default=function(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../shared/utils.js"),a=require("./utils.js");exports.default=function(t){var o;let{config:n,localizedPathnames:l,request:r,resolvedLocale:s}=t;const i=r.nextUrl.clone(),c=a.getHost(r.headers);function p(t,o){return t.pathname=e.normalizeTrailingSlash(t.pathname),r.nextUrl.basePath&&((t=new URL(t)).pathname=a.applyBasePath(t.pathname,r.nextUrl.basePath)),"<".concat(t.toString(),'>; rel="alternate"; hreflang="').concat(o,'"')}function m(e,t){return l&&"object"==typeof l?a.formatTemplatePathname(e,l[s],l[t]):e}c&&(i.port="",i.host=c),i.protocol=null!==(o=r.headers.get("x-forwarded-proto"))&&void 0!==o?o:i.protocol,i.pathname=a.getNormalizedPathname(i.pathname,n.locales,n.localePrefix);const h=a.getLocalePrefixes(n.locales,n.localePrefix).flatMap((e=>{let t,[o,r]=e;function s(e){return"/"===e?r:r+e}if(n.domains){return(n.domains.filter((e=>a.isLocaleSupportedOnDomain(o,e)))||[]).map((e=>(t=new URL(i),t.port="",t.host=e.domain,t.pathname=m(i.pathname,o),o===e.defaultLocale&&"always"!==n.localePrefix.mode||(t.pathname=s(t.pathname)),p(t,o))))}{let e;e=l&&"object"==typeof l?m(i.pathname,o):i.pathname,o===n.defaultLocale&&"always"!==n.localePrefix.mode||(e=s(e)),t=new URL(e,i)}return p(t,o)}));if(!n.domains&&("always"!==n.localePrefix.mode||"/"===i.pathname)){const e=new URL(m(i.pathname,n.defaultLocale),i);h.push(p(e,"x-default"))}return h.join(", ")};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/server"),a=require("../shared/constants.js"),t=require("../shared/utils.js"),r=require("./config.js"),l=require("./getAlternateLinksHeaderValue.js"),o=require("./resolveLocale.js"),n=require("./syncCookie.js"),s=require("./utils.js");exports.default=function(i){const c=r.receiveConfig(i);return function(r){var i;const d=decodeURI(r.nextUrl.pathname),{domain:f,locale:m}=o.default(c,r.headers,r.cookies,d),h=f?f.defaultLocale===m:m===c.defaultLocale,u=(null===(i=c.domains)||void 0===i?void 0:i.filter((e=>s.isLocaleSupportedOnDomain(m,e))))||[],x=null!=c.domains&&!f;function P(t){const l=new URL(t,r.url);r.nextUrl.basePath&&(l.pathname=s.applyBasePath(l.pathname,r.nextUrl.basePath));const o=new Headers(r.headers);return o.set(a.HEADER_LOCALE_NAME,m),e.NextResponse.rewrite(l,{request:{headers:o}})}function p(a,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/server"),a=require("../shared/constants.js"),t=require("../shared/utils.js"),r=require("./config.js"),l=require("./getAlternateLinksHeaderValue.js"),o=require("./resolveLocale.js"),n=require("./syncCookie.js"),s=require("./utils.js");exports.default=function(i){const c=r.receiveConfig(i);return function(r){var i;const d=decodeURI(r.nextUrl.pathname),{domain:f,locale:m}=o.default(c,r.headers,r.cookies,d),h=f?f.defaultLocale===m:m===c.defaultLocale,u=(null===(i=c.domains)||void 0===i?void 0:i.filter((e=>s.isLocaleSupportedOnDomain(m,e))))||[],x=null!=c.domains&&!f;function P(t){const l=new URL(t,r.url);r.nextUrl.basePath&&(l.pathname=s.applyBasePath(l.pathname,r.nextUrl.basePath));const o=new Headers(r.headers);return o.set(a.HEADER_LOCALE_NAME,m),e.NextResponse.rewrite(l,{request:{headers:o}})}function p(a,l){const o=new URL(t.normalizeTrailingSlash(a),r.url);if(u.length>0&&!l){const e=s.getBestMatchingDomain(f,m,u);e&&(l=e.domain,e.defaultLocale===m&&"as-needed"===c.localePrefix.mode&&(o.pathname=s.getNormalizedPathname(o.pathname,c.locales,c.localePrefix)))}var n,i;l&&(o.host=l,r.headers.get("x-forwarded-host")&&(o.protocol=null!==(n=r.headers.get("x-forwarded-proto"))&&void 0!==n?n:r.nextUrl.protocol,o.port=null!==(i=r.headers.get("x-forwarded-port"))&&void 0!==i?i:""));return r.nextUrl.basePath&&(o.pathname=s.applyBasePath(o.pathname,r.nextUrl.basePath)),e.NextResponse.redirect(o.toString())}const g=s.getNormalizedPathname(d,c.locales,c.localePrefix),v=s.getPathnameMatch(d,c.locales,c.localePrefix),L=null!=v,U="never"===c.localePrefix.mode||h&&"as-needed"===c.localePrefix.mode;let q,j,w=g;if(c.pathnames){let e;if([e,j]=s.getInternalTemplate(c.pathnames,g,m),j){const a=c.pathnames[j],l="string"==typeof a?a:a[m];if(t.matchesPathname(l,g))w=s.formatTemplatePathname(g,l,j);else{let o;o=e?"string"==typeof a?a:a[e]:j;const n=U?void 0:t.getLocalePrefix(m,c.localePrefix),i=s.formatTemplatePathname(g,o,l);q=p(s.formatPathname(i,n,r.nextUrl.search))}}}if(!q)if("/"!==w||L){const e=s.formatPathname(w,s.getLocaleAsPrefix(m),r.nextUrl.search);if(L){const a=s.formatPathname(g,v.prefix,r.nextUrl.search);if("never"===c.localePrefix.mode)q=p(s.formatPathname(g,void 0,r.nextUrl.search));else if(v.exact)if(h&&U)q=p(s.formatPathname(g,void 0,r.nextUrl.search));else if(c.domains){const t=s.getBestMatchingDomain(f,v.locale,u);q=(null==f?void 0:f.domain)===(null==t?void 0:t.domain)||x?P(e):p(a,null==t?void 0:t.domain)}else q=P(e);else q=p(a)}else q=U?P(e):p(s.formatPathname(g,t.getLocalePrefix(m,c.localePrefix),r.nextUrl.search))}else q=U?P(s.formatPathname(w,s.getLocaleAsPrefix(m),r.nextUrl.search)):p(s.formatPathname(g,t.getLocalePrefix(m,c.localePrefix),r.nextUrl.search));var y;(c.localeDetection&&n.default(r,q,m),"never"!==c.localePrefix.mode&&c.alternateLinks&&c.locales.length>1)&&q.headers.set("Link",l.default({config:c,localizedPathnames:null!=j?null===(y=c.pathnames)||void 0===y?void 0:y[j]:void 0,request:r,resolvedLocale:m}));return q}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../shared/utils.js");function t(t,n){return t.map((t=>[t,e.getLocalePrefix(t,n)]))}function n(t,n){const o=e.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../shared/utils.js");function t(t,n){return t.map((t=>[t,e.getLocalePrefix(t,n)]))}function n(t,n){const r=e.normalizeTrailingSlash(n),o=e.normalizeTrailingSlash(t),a=e.templateToRegex(o).exec(r);if(!a)return;const l={};for(let e=1;e<a.length;e++){var i;const t=null===(i=o.match(/\[([^\]]+)\]/g))||void 0===i?void 0:i[e-1].replace(/[[\]]/g,"");t&&(l[t]=a[e])}return l}function r(e,t){if(!t)return e;let n=e=e.replace(/\[\[/g,"[").replace(/\]\]/g,"]");return Object.entries(t).forEach((e=>{let[t,r]=e;n=n.replace("[".concat(t,"]"),r)})),n}function o(e,t){return t.defaultLocale===e||!t.locales||t.locales.includes(e)}exports.applyBasePath=function(t,n){return e.normalizeTrailingSlash(n+t)},exports.formatPathname=function(t,n,r){let o=t;return n&&(o=e.prefixPathname(n,o)),r&&(o+=r),o},exports.formatPathnameTemplate=r,exports.formatTemplatePathname=function(t,o,a,l){let i="";return i+=r(a,n(o,t)),i=e.normalizeTrailingSlash(i),i},exports.getBestMatchingDomain=function(e,t,n){let r;return e&&o(t,e)&&(r=e),r||(r=n.find((e=>e.defaultLocale===t))),r||(r=n.find((e=>null!=e.locales&&e.locales.includes(t)))),r||null!=(null==e?void 0:e.locales)||(r=e),r||(r=n.find((e=>!e.locales))),r},exports.getHost=function(e){var t,n;return null!==(t=null!==(n=e.get("x-forwarded-host"))&&void 0!==n?n:e.get("host"))&&void 0!==t?t:void 0},exports.getInternalTemplate=function(t,n,r){const o=e.getSortedPathnames(Object.keys(t));for(const a of o){const o=t[a];if("string"==typeof o){const t=o;if(e.matchesPathname(t,n))return[void 0,a]}else{const t=Object.entries(o),l=t.findIndex((e=>{let[t]=e;return t===r}));l>0&&t.unshift(t.splice(l,1)[0]);for(const[r,o]of t)if(e.matchesPathname(o,n))return[r,a]}}for(const r of Object.keys(t))if(e.matchesPathname(r,n))return[void 0,r];return[void 0,void 0]},exports.getLocaleAsPrefix=function(e){return"/".concat(e)},exports.getLocalePrefixes=t,exports.getNormalizedPathname=function(n,r,o){n.endsWith("/")||(n+="/");const a=t(r,o),l=new RegExp("^(".concat(a.map((e=>{let[,t]=e;return t.replaceAll("/","\\/")})).join("|"),")/(.*)"),"i"),i=n.match(l);let s=i?"/"+i[2]:n;return"/"!==s&&(s=e.normalizeTrailingSlash(s)),s},exports.getPathnameMatch=function(e,n,r){const o=t(n,r);for(const[t,n]of o){let r,o;if(e===n||e.startsWith(n+"/"))r=o=!0;else{const t=e.toLowerCase(),a=n.toLowerCase();(t===a||t.startsWith(a+"/"))&&(r=!1,o=!0)}if(o)return{locale:t,prefix:n,matchedPrefix:e.slice(0,n.length),exact:r}}},exports.getRouteParams=n,exports.isLocaleSupportedOnDomain=o;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var n=require("fs"),e=require("path");function t(n){return n&&n.__esModule?n:{default:n}}var
|
|
1
|
+
"use strict";var n=require("fs"),e=require("path");function t(n){return n&&n.__esModule?n:{default:n}}var o=t(n),r=t(e);function i(n,e){function t(n){return o.default.existsSync(function(n){const t=[];return e&&t.push(e),t.push(n),r.default.resolve(...t)}(n))}if(n){if(!t(n))throw new Error("Could not find i18n config at ".concat(n,", please provide a valid path."));return n}for(const n of["./i18n.tsx","./i18n.ts","./i18n.js","./i18n.jsx","./src/i18n.tsx","./src/i18n.ts","./src/i18n.js","./src/i18n.jsx"])if(t(n))return n;throw new Error("\n\nCould not locate i18n config. Create one at `./(src/)i18n.{js,jsx,ts,tsx}` or specify a custom location:\n\nconst withNextIntl = require('next-intl/plugin')(\n './path/to/i18n.tsx'\n);\n\nmodule.exports = withNextIntl({\n // Other Next.js configuration ...\n});\n")}module.exports=function(n){return function(e){return function(n,e){null!=(null==e?void 0:e.i18n)&&console.warn("\nnext-intl has found an `i18n` config in your next.config.js. This likely causes conflicts and should therefore be removed if you use the App Router.\n\nIf you're in progress of migrating from the `pages` folder, you can refer to this example: https://next-intl-docs.vercel.app/examples#app-router-migration\n");const t={};if(null!=process.env.TURBOPACK){var o,l;if(n&&n.startsWith("/"))throw new Error("Turbopack support for next-intl currently does not support absolute paths, please provide a relative one (e.g. './src/i18n/config.ts').\n\nFound: "+n+"\n");t.experimental={...null==e?void 0:e.experimental,turbo:{...null==e||null===(o=e.experimental)||void 0===o?void 0:o.turbo,resolveAlias:{...null==e||null===(l=e.experimental)||void 0===l||null===(l=l.turbo)||void 0===l?void 0:l.resolveAlias,"next-intl/config":i(n)}}}}else t.webpack=function(){for(var t=arguments.length,o=new Array(t),l=0;l<t;l++)o[l]=arguments[l];let[s,u]=o;return s.resolve.alias["next-intl/config"]=r.default.resolve(s.context,i(n,s.context)),"function"==typeof(null==e?void 0:e.webpack)?e.webpack(s,u):s};return t.env={...null==e?void 0:e.env,_next_intl_trailing_slash:null!=e&&e.trailingSlash?"true":void 0},Object.assign({},e,t)}(n,e)}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function
|
|
1
|
+
"use strict";function t(t){return function(t){return"object"==typeof t?null==t.host&&null==t.hostname:!/^[a-z]+:/i.test(t)}(t)&&!function(t){const e="object"==typeof t?t.pathname:t;return null!=e&&!e.startsWith("/")}(t)}function e(t,e){let r;return"string"==typeof t?r=n(e,t):(r={...t},t.pathname&&(r.pathname=n(e,t.pathname))),r}function n(t,e){let n=t;return/^\/(\?.*)?$/.test(e)&&(e=e.slice(1)),n+=e,n}function r(t,e){return e===t||e.startsWith("".concat(t,"/"))}function o(t){const e=function(){try{return"true"===process.env._next_intl_trailing_slash}catch(t){return!1}}();if("/"!==t){const n=t.endsWith("/");e&&!n?t+="/":!e&&n&&(t=t.slice(0,-1))}return t}function i(t){const e=t.replace(/\[\[(\.\.\.[^\]]+)\]\]/g,"?(.*)").replace(/\[(\.\.\.[^\]]+)\]/g,"(.+)").replace(/\[([^\]]+)\]/g,"([^/]+)");return new RegExp("^".concat(e,"$"))}function u(t){return t.includes("[[...")}function c(t){return t.includes("[...")}function s(t){return t.includes("[")}function a(t,e){const n=t.split("/"),r=e.split("/"),o=Math.max(n.length,r.length);for(let t=0;t<o;t++){const e=n[t],o=r[t];if(!e&&o)return-1;if(e&&!o)return 1;if(e||o){if(!s(e)&&s(o))return-1;if(s(e)&&!s(o))return 1;if(!c(e)&&c(o))return-1;if(c(e)&&!c(o))return 1;if(!u(e)&&u(o))return-1;if(u(e)&&!u(o))return 1}}return 0}Object.defineProperty(exports,"__esModule",{value:!0}),exports.getLocalePrefix=function(t,e){var n;return"never"!==e.mode&&(null===(n=e.prefixes)||void 0===n?void 0:n[t])||"/"+t},exports.getSortedPathnames=function(t){return t.sort(a)},exports.hasPathnamePrefixed=r,exports.isLocalizableHref=t,exports.localizeHref=function(n,o){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:o,u=arguments.length>3?arguments[3]:void 0,c=arguments.length>4?arguments[4]:void 0;if(!t(n))return n;const s=o!==i,a=r(c,u);return(s||a)&&null!=c?e(n,c):n},exports.matchesPathname=function(t,e){const n=o(t),r=o(e);return i(n).test(r)},exports.normalizeTrailingSlash=o,exports.prefixHref=e,exports.prefixPathname=n,exports.templateToRegex=i,exports.unprefixPathname=function(t,e){return t.replace(new RegExp("^".concat(e)),"")||"/"};
|
|
@@ -21,5 +21,4 @@ export declare function getHost(requestHeaders: Headers): string | undefined;
|
|
|
21
21
|
export declare function isLocaleSupportedOnDomain<AppLocales extends Locales>(locale: string, domain: DomainConfig<AppLocales>): boolean;
|
|
22
22
|
export declare function getBestMatchingDomain<AppLocales extends Locales>(curHostDomain: DomainConfig<AppLocales> | undefined, locale: string, domainsConfig: DomainsConfig<AppLocales>): DomainConfig<AppLocales> | undefined;
|
|
23
23
|
export declare function applyBasePath(pathname: string, basePath: string): string;
|
|
24
|
-
export declare function normalizeTrailingSlash(pathname: string): string;
|
|
25
24
|
export declare function getLocaleAsPrefix<AppLocales extends Locales>(locale: AppLocales[number]): string;
|
|
@@ -12,6 +12,7 @@ export declare function prefixHref(href: UrlObject | string, prefix: string): Ur
|
|
|
12
12
|
export declare function unprefixPathname(pathname: string, prefix: string): string;
|
|
13
13
|
export declare function prefixPathname(prefix: string, pathname: string): string;
|
|
14
14
|
export declare function hasPathnamePrefixed(prefix: string, pathname: string): boolean;
|
|
15
|
+
export declare function normalizeTrailingSlash(pathname: string): string;
|
|
15
16
|
export declare function matchesPathname(
|
|
16
17
|
/** E.g. `/users/[userId]-[userName]` */
|
|
17
18
|
template: string,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intl",
|
|
3
|
-
"version": "3.15.
|
|
3
|
+
"version": "3.15.6-canary.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.work>",
|
|
6
6
|
"funding": [
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"dependencies": {
|
|
88
88
|
"@formatjs/intl-localematcher": "^0.2.32",
|
|
89
89
|
"negotiator": "^0.6.3",
|
|
90
|
-
"use-intl": "^3.15.
|
|
90
|
+
"use-intl": "^3.15.6-canary.0"
|
|
91
91
|
},
|
|
92
92
|
"peerDependencies": {
|
|
93
93
|
"next": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0",
|
|
@@ -104,11 +104,11 @@
|
|
|
104
104
|
},
|
|
105
105
|
{
|
|
106
106
|
"path": "dist/production/navigation.react-client.js",
|
|
107
|
-
"limit": "3.
|
|
107
|
+
"limit": "3.465 KB"
|
|
108
108
|
},
|
|
109
109
|
{
|
|
110
110
|
"path": "dist/production/navigation.react-server.js",
|
|
111
|
-
"limit": "
|
|
111
|
+
"limit": "18.075 KB"
|
|
112
112
|
},
|
|
113
113
|
{
|
|
114
114
|
"path": "dist/production/server.react-client.js",
|
|
@@ -120,12 +120,12 @@
|
|
|
120
120
|
},
|
|
121
121
|
{
|
|
122
122
|
"path": "dist/production/middleware.js",
|
|
123
|
-
"limit": "6.
|
|
123
|
+
"limit": "6.485 KB"
|
|
124
124
|
},
|
|
125
125
|
{
|
|
126
126
|
"path": "dist/production/routing.js",
|
|
127
127
|
"limit": "0 KB"
|
|
128
128
|
}
|
|
129
129
|
],
|
|
130
|
-
"gitHead": "
|
|
130
|
+
"gitHead": "cfa1da34b64be5aedbb818f486b622e19b086fe5"
|
|
131
131
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/types/{test → src}/navigation/react-client/createSharedPathnamesNavigation.test.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|