From 87db12c2134f5416d091e3b0a5a963686b1f46a9 Mon Sep 17 00:00:00 2001 From: gelove Date: Thu, 15 May 2025 16:39:09 +0800 Subject: [PATCH 1/2] Fix href function return empty string --- packages/react-router/lib/href.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/react-router/lib/href.ts b/packages/react-router/lib/href.ts index 6f0523d1ef..0d93281dcf 100644 --- a/packages/react-router/lib/href.ts +++ b/packages/react-router/lib/href.ts @@ -23,6 +23,9 @@ type ToArgs = Returns a resolved URL path for the specified route. ```tsx + const h = href("/:lang?", {}) + // -> `/` + const h = href("/:lang?/about", { lang: "en" }) // -> `/en/about` @@ -51,5 +54,5 @@ export function href( return value; }) .filter((segment) => segment !== undefined) - .join("/"); + .join("/") || "/"; } From 70f2c93e9a0142716f2904896b01a3d9c2c6f02b Mon Sep 17 00:00:00 2001 From: Allen Date: Fri, 16 May 2025 13:34:39 +0800 Subject: [PATCH 2/2] Fix href function return empty string if href function return empty string, the url don't change when click the link. --- contributors.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/contributors.yml b/contributors.yml index 329dfae023..9b8e51e886 100644 --- a/contributors.yml +++ b/contributors.yml @@ -115,6 +115,7 @@ - gatzjames - gavriguy - Geist5000 +- gelove - gesposito - gianlucca - gijo-varghese