fix: remove manual encodeURIComponent from pathUtils (react-router v7 encodes automatically)
react-router v7's generatePath() now calls encodeURIComponent() on all path params. pathUtils.ts was also calling encodeURIComponent() before passing to generatePath, resulting in double-encoding (e.g. '#' became '%2523' instead of '%23'). This caused spaces/rooms with alias paths to receive double-encoded room IDs from useParams(), which were then re-encoded by matrix-sdk when making HTTP requests (400 Bad Request from Synapse). Remove the manual encodeURIComponent() calls -- generatePath handles it.
This commit is contained in:
+14
-14
@@ -73,17 +73,17 @@ export const getAppPathFromHref = (baseUrl: string, href: string): string => {
|
||||
export const getRootPath = (): string => ROOT_PATH;
|
||||
|
||||
export const getLoginPath = (server?: string): string => {
|
||||
const params = server ? { server: encodeURIComponent(server) } : undefined;
|
||||
const params = server ? { server } : undefined;
|
||||
return generatePath(LOGIN_PATH, params);
|
||||
};
|
||||
|
||||
export const getRegisterPath = (server?: string): string => {
|
||||
const params = server ? { server: encodeURIComponent(server) } : undefined;
|
||||
const params = server ? { server } : undefined;
|
||||
return generatePath(REGISTER_PATH, params);
|
||||
};
|
||||
|
||||
export const getResetPasswordPath = (server?: string): string => {
|
||||
const params = server ? { server: encodeURIComponent(server) } : undefined;
|
||||
const params = server ? { server } : undefined;
|
||||
return generatePath(RESET_PASSWORD_PATH, params);
|
||||
};
|
||||
|
||||
@@ -93,8 +93,8 @@ export const getHomeJoinPath = (): string => HOME_JOIN_PATH;
|
||||
export const getHomeSearchPath = (): string => HOME_SEARCH_PATH;
|
||||
export const getHomeRoomPath = (roomIdOrAlias: string, eventId?: string): string => {
|
||||
const params = {
|
||||
roomIdOrAlias: encodeURIComponent(roomIdOrAlias),
|
||||
eventId: eventId ? encodeURIComponent(eventId) : null,
|
||||
roomIdOrAlias,
|
||||
eventId: eventId ?? null,
|
||||
};
|
||||
|
||||
return generatePath(HOME_ROOM_PATH, params);
|
||||
@@ -104,8 +104,8 @@ export const getDirectPath = (): string => DIRECT_PATH;
|
||||
export const getDirectCreatePath = (): string => DIRECT_CREATE_PATH;
|
||||
export const getDirectRoomPath = (roomIdOrAlias: string, eventId?: string): string => {
|
||||
const params = {
|
||||
roomIdOrAlias: encodeURIComponent(roomIdOrAlias),
|
||||
eventId: eventId ? encodeURIComponent(eventId) : null,
|
||||
roomIdOrAlias,
|
||||
eventId: eventId ?? null,
|
||||
};
|
||||
|
||||
return generatePath(DIRECT_ROOM_PATH, params);
|
||||
@@ -113,20 +113,20 @@ export const getDirectRoomPath = (roomIdOrAlias: string, eventId?: string): stri
|
||||
|
||||
export const getSpacePath = (spaceIdOrAlias: string): string => {
|
||||
const params = {
|
||||
spaceIdOrAlias: encodeURIComponent(spaceIdOrAlias),
|
||||
spaceIdOrAlias,
|
||||
};
|
||||
|
||||
return generatePath(SPACE_PATH, params);
|
||||
};
|
||||
export const getSpaceLobbyPath = (spaceIdOrAlias: string): string => {
|
||||
const params = {
|
||||
spaceIdOrAlias: encodeURIComponent(spaceIdOrAlias),
|
||||
spaceIdOrAlias,
|
||||
};
|
||||
return generatePath(SPACE_LOBBY_PATH, params);
|
||||
};
|
||||
export const getSpaceSearchPath = (spaceIdOrAlias: string): string => {
|
||||
const params = {
|
||||
spaceIdOrAlias: encodeURIComponent(spaceIdOrAlias),
|
||||
spaceIdOrAlias,
|
||||
};
|
||||
return generatePath(SPACE_SEARCH_PATH, params);
|
||||
};
|
||||
@@ -136,9 +136,9 @@ export const getSpaceRoomPath = (
|
||||
eventId?: string,
|
||||
): string => {
|
||||
const params = {
|
||||
spaceIdOrAlias: encodeURIComponent(spaceIdOrAlias),
|
||||
roomIdOrAlias: encodeURIComponent(roomIdOrAlias),
|
||||
eventId: eventId ? encodeURIComponent(eventId) : null,
|
||||
spaceIdOrAlias,
|
||||
roomIdOrAlias,
|
||||
eventId: eventId ?? null,
|
||||
};
|
||||
|
||||
return generatePath(SPACE_ROOM_PATH, params);
|
||||
@@ -148,7 +148,7 @@ export const getExplorePath = (): string => EXPLORE_PATH;
|
||||
export const getExploreFeaturedPath = (): string => EXPLORE_FEATURED_PATH;
|
||||
export const getExploreServerPath = (server: string): string => {
|
||||
const params = {
|
||||
server: encodeURIComponent(server),
|
||||
server,
|
||||
};
|
||||
return generatePath(EXPLORE_SERVER_PATH, params);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user