Skip to content

Commit bca0a97

Browse files
authored
Merge pull request #272 from IFRCGo/fix/surge-redirects
Add remaining surge redirects
2 parents 4054e64 + bb9f9b7 commit bca0a97

File tree

24 files changed

+405
-90
lines changed

24 files changed

+405
-90
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"react": "^18.2.0",
4747
"react-dom": "^18.2.0",
4848
"react-focus-on": "^3.8.1",
49-
"react-router-dom": "^6.11.1",
49+
"react-router-dom": "^6.18.0",
5050
"sanitize-html": "^2.10.0",
5151
"url": "^0.11.0"
5252
},

src/App/routes/SmartNavigate.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,28 @@ type RouteKey = string;
99

1010
interface Props extends NavigateProps {
1111
hashToRouteMap: Record<string, RouteKey>;
12+
forwardUnmatchedHashTo?: string;
1213
}
1314

1415
function SmartNavigate(props: Props) {
1516
const {
1617
hashToRouteMap,
18+
forwardUnmatchedHashTo,
1719
...navigateProps
1820
} = props;
21+
1922
const location = useLocation();
2023
const newRoute = isTruthyString(location.hash)
21-
? hashToRouteMap[location.hash]
24+
? (hashToRouteMap[location.hash] ?? forwardUnmatchedHashTo)
2225
: undefined;
2326

2427
if (isDefined(newRoute)) {
2528
return (
2629
<Navigate
27-
to={newRoute}
30+
to={{
31+
pathname: newRoute,
32+
hash: location.hash,
33+
}}
2834
replace
2935
/>
3036
);

0 commit comments

Comments
 (0)