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.
@@ -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.isLocalHref(params.pathname) ? params.pathname : utils.prefixPathname(prefix, params.pathname);
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,isLocalHref 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};
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};
@@ -1 +1 @@
1
- function n(n){const t="object"==typeof n?n.pathname:n;return null!=t&&!t.startsWith("/")}function t(n){if("object"==typeof n)return null==n.host&&null==n.hostname;return!/^[a-z]+:/i.test(n)}function e(e){return t(e)&&!n(e)}function r(n,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,i=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0;if(!e(n))return n;const f=t!==r,l=c(o,i);return(f||l)&&null!=o?u(n,o):n}function u(n,t){let e;return"string"==typeof n?e=o(t,n):(e={...n},n.pathname&&(e.pathname=o(t,n.pathname))),e}function i(n,t){return n.replace(new RegExp("^".concat(t)),"")||"/"}function o(n,t){let e=n;return/^\/(\?.*)?$/.test(t)&&(t=t.slice(1)),e+=t,e}function c(n,t){return t===n||t.startsWith("".concat(n,"/"))}function f(n,t){return s(n).test(t)}function l(n,t){var e;return"never"!==t.mode&&(null===(e=t.prefixes)||void 0===e?void 0:e[n])||"/"+n}function s(n){const t=n.replace(/\[\[(\.\.\.[^\]]+)\]\]/g,"?(.*)").replace(/\[(\.\.\.[^\]]+)\]/g,"(.+)").replace(/\[([^\]]+)\]/g,"([^/]+)");return new RegExp("^".concat(t,"$"))}function a(n){return n.includes("[[...")}function p(n){return n.includes("[...")}function h(n){return n.includes("[")}function g(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(!h(t)&&h(u))return-1;if(h(t)&&!h(u))return 1;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}return 0}function d(n){return n.sort(g)}export{l as getLocalePrefix,d as getSortedPathnames,c as hasPathnamePrefixed,t as isLocalHref,e as isLocalizableHref,n as isRelativeHref,r as localizeHref,f as matchesPathname,u as prefixHref,o as prefixPathname,s as templateToRegex,i as unprefixPathname};
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.isLocalHref(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
+ "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){const t="object"==typeof e?e.pathname:e;return null!=t&&!t.startsWith("/")}function t(e){if("object"==typeof e)return null==e.host&&null==e.hostname;return!/^[a-z]+:/i.test(e)}function n(n){return t(n)&&!e(n)}function r(e,t){let n;return"string"==typeof e?n=o(t,e):(n={...e},e.pathname&&(n.pathname=o(t,e.pathname))),n}function o(e,t){let n=e;return/^\/(\?.*)?$/.test(t)&&(t=t.slice(1)),n+=t,n}function i(e,t){return t===e||t.startsWith("".concat(e,"/"))}function u(e){const t=e.replace(/\[\[(\.\.\.[^\]]+)\]\]/g,"?(.*)").replace(/\[(\.\.\.[^\]]+)\]/g,"(.+)").replace(/\[([^\]]+)\]/g,"([^/]+)");return new RegExp("^".concat(t,"$"))}function s(e){return e.includes("[[...")}function c(e){return e.includes("[...")}function a(e){return e.includes("[")}function f(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(!a(t)&&a(o))return-1;if(a(t)&&!a(o))return 1;if(!c(t)&&c(o))return-1;if(c(t)&&!c(o))return 1;if(!s(t)&&s(o))return-1;if(s(t)&&!s(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(f)},exports.hasPathnamePrefixed=i,exports.isLocalHref=t,exports.isLocalizableHref=n,exports.isRelativeHref=e,exports.localizeHref=function(e,t){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,u=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0;if(!n(e))return e;const c=t!==o,a=i(s,u);return(c||a)&&null!=s?r(e,s):e},exports.matchesPathname=function(e,t){return u(e).test(t)},exports.prefixHref=r,exports.prefixPathname=o,exports.templateToRegex=u,exports.unprefixPathname=function(e,t){return e.replace(new RegExp("^".concat(t)),"")||"/"};
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.4",
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.4"
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": "cb005a5680d06a6d78cef974b9b9e4deec3d2488"
130
+ "gitHead": "fba276245b20db29691417609a01ed5f7a9b9fc8"
131
131
  }