Skip to content

Commit

Permalink
Merge pull request #272 from IFRCGo/fix/surge-redirects
Browse files Browse the repository at this point in the history
Add remaining surge redirects
  • Loading branch information
tnagorra authored Nov 1, 2023
2 parents 4054e64 + bb9f9b7 commit bca0a97
Show file tree
Hide file tree
Showing 24 changed files with 405 additions and 90 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-focus-on": "^3.8.1",
"react-router-dom": "^6.11.1",
"react-router-dom": "^6.18.0",
"sanitize-html": "^2.10.0",
"url": "^0.11.0"
},
Expand Down
10 changes: 8 additions & 2 deletions src/App/routes/SmartNavigate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,28 @@ type RouteKey = string;

interface Props extends NavigateProps {
hashToRouteMap: Record<string, RouteKey>;
forwardUnmatchedHashTo?: string;
}

function SmartNavigate(props: Props) {
const {
hashToRouteMap,
forwardUnmatchedHashTo,
...navigateProps
} = props;

const location = useLocation();
const newRoute = isTruthyString(location.hash)
? hashToRouteMap[location.hash]
? (hashToRouteMap[location.hash] ?? forwardUnmatchedHashTo)
: undefined;

if (isDefined(newRoute)) {
return (
<Navigate
to={newRoute}
to={{
pathname: newRoute,
hash: location.hash,
}}
replace
/>
);
Expand Down
Loading

0 comments on commit bca0a97

Please sign in to comment.