Skip to content

Commit 9ad4710

Browse files
committed
fix: Fix route param decoding after React Router upgrade
After upgrading React Router, route params containing encoded characters are no longer automatically decoded. This caused values being re-encoded during navigation, resulting in invalid primary key errors. This change decodes params immediately after matchPath to prevent double encoding. Signed-off-by: Jasmina <jasmina.piric@secomind.com>
1 parent 231c287 commit 9ad4710

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

frontend/src/Navigation.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,15 @@ const matchingParametricRoute = (
107107
return null;
108108
}
109109

110-
const params = matchPath(route, path)?.params;
110+
const rawParams = matchPath(route, path)?.params;
111+
const params = rawParams
112+
? Object.fromEntries(
113+
Object.entries(rawParams).map(([key, value]) => [
114+
key,
115+
typeof value === "string" ? decodeURIComponent(value) : value,
116+
]),
117+
)
118+
: undefined;
111119
switch (route) {
112120
case Route.devices:
113121
case Route.deviceGroups:

0 commit comments

Comments
 (0)