Skip to content

Commit 4106641

Browse files
committed
fix: Merge remote-tracking branch 'origin/main' into v4
2 parents 1a5e0ec + 663c539 commit 4106641

9 files changed

+71
-7
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## 3.26.5 (2025-02-21)
7+
8+
### Bug Fixes
9+
10+
* Handle `query` in `<Link />` correctly when using `localePrefix: 'as-needed'` with `domains` ([#1732](https://github.com/amannn/next-intl/issues/1732)) ([ec8776e](https://github.com/amannn/next-intl/commit/ec8776e8f0344f78fea4f71284c48312484a7059)), closes [#1731](https://github.com/amannn/next-intl/issues/1731) – by @amannn
11+
612
## 3.26.4 (2025-02-18)
713

814
### Bug Fixes

lerna.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "node_modules/@lerna-lite/cli/schemas/lerna-schema.json",
3-
"version": "3.26.4",
3+
"version": "3.26.5",
44
"packages": [
55
"packages/*"
66
],

packages/next-intl/.size-limit.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ const config: SizeLimitConfig = [
2121
name: "import {createNavigation} from 'next-intl/navigation' (react-client)",
2222
path: 'dist/esm/production/navigation.react-client.js',
2323
import: '{createNavigation}',
24-
limit: '2.475 KB'
24+
limit: '2.485 KB'
2525
},
2626
{
2727
name: "import {createNavigation} from 'next-intl/navigation' (react-server)",
2828
path: 'dist/esm/production/navigation.react-server.js',
2929
import: '{createNavigation}',
30-
limit: '3.255 KB'
30+
limit: '3.275 KB'
3131
},
3232
{
3333
name: "import * from 'next-intl/server' (react-client)",

packages/next-intl/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## 3.26.5 (2025-02-21)
7+
8+
### Bug Fixes
9+
10+
* Handle `query` in `<Link />` correctly when using `localePrefix: 'as-needed'` with `domains` ([#1732](https://github.com/amannn/next-intl/issues/1732)) ([ec8776e](https://github.com/amannn/next-intl/commit/ec8776e8f0344f78fea4f71284c48312484a7059)), closes [#1731](https://github.com/amannn/next-intl/issues/1731) – by @amannn
11+
612
## 3.26.4 (2025-02-18)
713

814
### Bug Fixes

packages/next-intl/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "next-intl",
3-
"version": "3.26.4",
3+
"version": "3.26.5",
44
"sideEffects": false,
55
"author": "Jan Amann <jan@amann.work>",
66
"funding": [

packages/next-intl/src/navigation/createNavigation.test.tsx

+42
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,15 @@ describe.each([
961961
);
962962
expect(markup).toContain('href="/de/about"');
963963
});
964+
965+
it('accepts search params', () => {
966+
render(
967+
<Link href={{pathname: '/about', query: {foo: 'bar'}}}>Test</Link>
968+
);
969+
expect(
970+
screen.getByRole('link', {name: 'Test'}).getAttribute('href')
971+
).toBe('/about?foo=bar');
972+
});
964973
});
965974

966975
describe('getPathname', () => {
@@ -1015,6 +1024,39 @@ describe.each([
10151024
});
10161025
});
10171026

1027+
describe("localePrefix: 'as-needed', with `domains` and `pathnames`", () => {
1028+
const {Link, permanentRedirect, redirect} = createNavigation({
1029+
locales,
1030+
defaultLocale,
1031+
domains,
1032+
localePrefix: 'as-needed',
1033+
pathnames
1034+
});
1035+
1036+
describe('Link', () => {
1037+
it('accepts search params', () => {
1038+
render(
1039+
<Link href={{pathname: '/about', query: {foo: 'bar'}}}>Test</Link>
1040+
);
1041+
expect(
1042+
screen.getByRole('link', {name: 'Test'}).getAttribute('href')
1043+
).toBe('/about?foo=bar');
1044+
});
1045+
});
1046+
1047+
describe.each([
1048+
['redirect', redirect, nextRedirect],
1049+
['permanentRedirect', permanentRedirect, nextPermanentRedirect]
1050+
])('%s', (_, redirectFn, nextRedirectFn) => {
1051+
it('accepts search params', () => {
1052+
runInRender(() =>
1053+
redirectFn({href: {pathname: '/', query: {foo: 'bar'}}, locale: 'en'})
1054+
);
1055+
expect(nextRedirectFn).toHaveBeenLastCalledWith('/en?foo=bar');
1056+
});
1057+
});
1058+
});
1059+
10181060
describe("localePrefix: 'never'", () => {
10191061
const {Link, getPathname, permanentRedirect, redirect} = createNavigation({
10201062
locales,

packages/next-intl/src/navigation/shared/createSharedNavigationFns.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,10 @@ export default function createSharedNavigationFns<
9494
{href, locale, ...rest}: LinkProps<Pathname>,
9595
ref: ComponentProps<typeof BaseLink>['ref']
9696
) {
97-
let pathname, params;
97+
let pathname, params, query;
9898
if (typeof href === 'object') {
9999
pathname = href.pathname;
100+
query = href.query;
100101
// @ts-expect-error -- This is ok
101102
params = href.params;
102103
} else {
@@ -154,7 +155,10 @@ export default function createSharedNavigationFns<
154155
// @ts-expect-error -- This is ok
155156
{
156157
locale: curLocale,
157-
href: pathnames == null ? pathname : {pathname, params}
158+
href:
159+
pathnames == null
160+
? {pathname, query}
161+
: {pathname, query, params}
158162
},
159163
false
160164
)

packages/use-intl/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## 3.26.5 (2025-02-21)
7+
8+
### Bug Fixes
9+
10+
* Handle `query` in `<Link />` correctly when using `localePrefix: 'as-needed'` with `domains` ([#1732](https://github.com/amannn/next-intl/issues/1732)) ([ec8776e](https://github.com/amannn/next-intl/commit/ec8776e8f0344f78fea4f71284c48312484a7059)), closes [#1731](https://github.com/amannn/next-intl/issues/1731) – by @amannn
11+
612
## 3.26.4 (2025-02-18)
713

814
### Bug Fixes

packages/use-intl/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "use-intl",
3-
"version": "3.26.4",
3+
"version": "3.26.5",
44
"sideEffects": false,
55
"author": "Jan Amann <jan@amann.work>",
66
"description": "Internationalization (i18n) for React",

0 commit comments

Comments
 (0)