Skip to content

Commit

Permalink
Fix invalid url being built when navigating analysis modes
Browse files Browse the repository at this point in the history
  • Loading branch information
JoaquinTrinanes committed Nov 8, 2022
1 parent 6c7e9b6 commit 79f672b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
8 changes: 8 additions & 0 deletions client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/).

## Unreleased

## [v0.2.3]

### Fixed

- Switching between comparison modes not working [LANDGRIF-1033](https://vizzuality.atlassian.net/browse/LLANDGRIF-1033)

## [v0.2.2]

### Fixed

- Filters resetting when switching scenario [LANDGRIF-1021](https://vizzuality.atlassian.net/browse/LLANDGRIF-1021)

## [v0.2.1]
Expand Down
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "landgriffon-client",
"version": "0.2.2",
"version": "0.2.3",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
8 changes: 2 additions & 6 deletions client/src/hooks/queryParam/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ const parse = <T>(value: string): T => {
}
};

const window = typeof global.window === 'undefined' ? null : global.window;

const useQueryParam = <T, F = T>(
name: string,
{
Expand Down Expand Up @@ -90,10 +88,8 @@ const useQueryParam = <T, F = T>(

useEffect(() => {
const handleParam = (href: string) => {
const url = new URL(`${window.location.host}${href}`);
const newQueryStr = Object.fromEntries(url.searchParams.entries())[name];

const value = parse<T>(newQueryStr);
const params = new URLSearchParams(href.split('?')[1]);
const value = parse<T>(params.get(name) || undefined);

setValue(value);
};
Expand Down

1 comment on commit 79f672b

@vercel
Copy link

@vercel vercel bot commented on 79f672b Nov 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.