next-intl 3.15.4 → 3.15.5
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/navigation/shared/redirects.js +1 -1
- package/dist/development/shared/utils.js +0 -2
- package/dist/esm/navigation/shared/redirects.js +1 -1
- package/dist/esm/shared/utils.js +1 -1
- package/dist/production/navigation/shared/redirects.js +1 -1
- package/dist/production/shared/utils.js +1 -1
- package/dist/types/src/shared/utils.d.ts +0 -2
- package/package.json +3 -3
|
@@ -8,7 +8,7 @@ var utils = require('../../shared/utils.js');
|
|
|
8
8
|
function createRedirectFn(redirectFn) {
|
|
9
9
|
return function baseRedirect(params) {
|
|
10
10
|
const prefix = utils.getLocalePrefix(params.locale, params.localePrefix);
|
|
11
|
-
const localizedPathname = params.localePrefix.mode === 'never' || !utils.
|
|
11
|
+
const localizedPathname = params.localePrefix.mode === 'never' || !utils.isLocalizableHref(params.pathname) ? params.pathname : utils.prefixPathname(prefix, params.pathname);
|
|
12
12
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
13
13
|
args[_key - 1] = arguments[_key];
|
|
14
14
|
}
|
|
@@ -134,9 +134,7 @@ function getSortedPathnames(pathnames) {
|
|
|
134
134
|
exports.getLocalePrefix = getLocalePrefix;
|
|
135
135
|
exports.getSortedPathnames = getSortedPathnames;
|
|
136
136
|
exports.hasPathnamePrefixed = hasPathnamePrefixed;
|
|
137
|
-
exports.isLocalHref = isLocalHref;
|
|
138
137
|
exports.isLocalizableHref = isLocalizableHref;
|
|
139
|
-
exports.isRelativeHref = isRelativeHref;
|
|
140
138
|
exports.localizeHref = localizeHref;
|
|
141
139
|
exports.matchesPathname = matchesPathname;
|
|
142
140
|
exports.prefixHref = prefixHref;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{redirect as e,permanentRedirect as n}from"next/navigation";import{getLocalePrefix as r,
|
|
1
|
+
import{redirect as e,permanentRedirect as n}from"next/navigation";import{getLocalePrefix as r,isLocalizableHref as t,prefixPathname as o}from"../../shared/utils.js";function a(e){return function(n){const a=r(n.locale,n.localePrefix),i="never"!==n.localePrefix.mode&&t(n.pathname)?o(a,n.pathname):n.pathname;for(var l=arguments.length,m=new Array(l>1?l-1:0),c=1;c<l;c++)m[c-1]=arguments[c];return e(i,...m)}}const i=a(e),l=a(n);export{l as basePermanentRedirect,i as baseRedirect};
|
package/dist/esm/shared/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function n(n){
|
|
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,o=arguments.length>3?arguments[3]:void 0,c=arguments.length>4?arguments[4]:void 0;if(!n(t))return t;const f=r!==u,l=i(c,o);return(f||l)&&null!=c?e(t,c):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 o(n,t){return f(n).test(t)}function c(n,t){var e;return"never"!==t.mode&&(null===(e=t.prefixes)||void 0===e?void 0:e[n])||"/"+n}function f(n){const t=n.replace(/\[\[(\.\.\.[^\]]+)\]\]/g,"?(.*)").replace(/\[(\.\.\.[^\]]+)\]/g,"(.+)").replace(/\[([^\]]+)\]/g,"([^/]+)");return new RegExp("^".concat(t,"$"))}function l(n){return n.includes("[[...")}function s(n){return n.includes("[...")}function a(n){return n.includes("[")}function p(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(!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;if(!l(t)&&l(u))return-1;if(l(t)&&!l(u))return 1}return 0}function h(n){return n.sort(p)}export{c as getLocalePrefix,h as getSortedPathnames,i as hasPathnamePrefixed,n as isLocalizableHref,t as localizeHref,o as matchesPathname,e as prefixHref,u as prefixPathname,f as templateToRegex,r as unprefixPathname};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/navigation"),r=require("../../shared/utils.js");function t(e){return function(t){const a=r.getLocalePrefix(t.locale,t.localePrefix),n="never"!==t.localePrefix.mode&&r.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/navigation"),r=require("../../shared/utils.js");function t(e){return function(t){const a=r.getLocalePrefix(t.locale,t.localePrefix),n="never"!==t.localePrefix.mode&&r.isLocalizableHref(t.pathname)?r.prefixPathname(a,t.pathname):t.pathname;for(var i=arguments.length,o=new Array(i>1?i-1:0),c=1;c<i;c++)o[c-1]=arguments[c];return e(n,...o)}}const a=t(e.redirect),n=t(e.permanentRedirect);exports.basePermanentRedirect=n,exports.baseRedirect=a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function e(e){
|
|
1
|
+
"use strict";function e(e){return function(e){return"object"==typeof e?null==e.host&&null==e.hostname:!/^[a-z]+:/i.test(e)}(e)&&!function(e){const t="object"==typeof e?e.pathname:e;return null!=t&&!t.startsWith("/")}(e)}function t(e,t){let r;return"string"==typeof e?r=n(t,e):(r={...e},e.pathname&&(r.pathname=n(t,e.pathname))),r}function n(e,t){let n=e;return/^\/(\?.*)?$/.test(t)&&(t=t.slice(1)),n+=t,n}function r(e,t){return t===e||t.startsWith("".concat(e,"/"))}function o(e){const t=e.replace(/\[\[(\.\.\.[^\]]+)\]\]/g,"?(.*)").replace(/\[(\.\.\.[^\]]+)\]/g,"(.+)").replace(/\[([^\]]+)\]/g,"([^/]+)");return new RegExp("^".concat(t,"$"))}function u(e){return e.includes("[[...")}function i(e){return e.includes("[...")}function c(e){return e.includes("[")}function s(e,t){const n=e.split("/"),r=t.split("/"),o=Math.max(n.length,r.length);for(let e=0;e<o;e++){const t=n[e],o=r[e];if(!t&&o)return-1;if(t&&!o)return 1;if(!c(t)&&c(o))return-1;if(c(t)&&!c(o))return 1;if(!i(t)&&i(o))return-1;if(i(t)&&!i(o))return 1;if(!u(t)&&u(o))return-1;if(u(t)&&!u(o))return 1}return 0}Object.defineProperty(exports,"__esModule",{value:!0}),exports.getLocalePrefix=function(e,t){var n;return"never"!==t.mode&&(null===(n=t.prefixes)||void 0===n?void 0:n[e])||"/"+e},exports.getSortedPathnames=function(e){return e.sort(s)},exports.hasPathnamePrefixed=r,exports.isLocalizableHref=e,exports.localizeHref=function(n,o){let u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:o,i=arguments.length>3?arguments[3]:void 0,c=arguments.length>4?arguments[4]:void 0;if(!e(n))return n;const s=o!==u,a=r(c,i);return(s||a)&&null!=c?t(n,c):n},exports.matchesPathname=function(e,t){return o(e).test(t)},exports.prefixHref=t,exports.prefixPathname=n,exports.templateToRegex=o,exports.unprefixPathname=function(e,t){return e.replace(new RegExp("^".concat(t)),"")||"/"};
|
|
@@ -4,8 +4,6 @@ import NextLink from 'next/link';
|
|
|
4
4
|
import { ComponentProps } from 'react';
|
|
5
5
|
import { Locales, LocalePrefixConfigVerbose } from '../routing/types';
|
|
6
6
|
type Href = ComponentProps<typeof NextLink>['href'];
|
|
7
|
-
export declare function isRelativeHref(href: Href): boolean;
|
|
8
|
-
export declare function isLocalHref(href: Href): boolean;
|
|
9
7
|
export declare function isLocalizableHref(href: Href): boolean;
|
|
10
8
|
export declare function localizeHref(href: string, locale: string, curLocale: string, curPathname: string, prefix: string): string;
|
|
11
9
|
export declare function localizeHref(href: UrlObject | string, locale: string, curLocale: string, curPathname: string, prefix: string): UrlObject | string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intl",
|
|
3
|
-
"version": "3.15.
|
|
3
|
+
"version": "3.15.5",
|
|
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.5"
|
|
91
91
|
},
|
|
92
92
|
"peerDependencies": {
|
|
93
93
|
"next": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0",
|
|
@@ -127,5 +127,5 @@
|
|
|
127
127
|
"limit": "0 KB"
|
|
128
128
|
}
|
|
129
129
|
],
|
|
130
|
-
"gitHead": "
|
|
130
|
+
"gitHead": "fba276245b20db29691417609a01ed5f7a9b9fc8"
|
|
131
131
|
}
|