Skip to content

Commit

Permalink
remove try-catch logic, add new test
Browse files Browse the repository at this point in the history
  • Loading branch information
alexvarney committed Dec 2, 2020
1 parent 1781c81 commit 5aab429
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 9 additions & 0 deletions packages/url-persistence/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,15 @@ describe('with URL persistence', () => {
);
});

it('should read state from query params with special chars', async () => {
window.location.hash =
'/work?activity=%25%2B-%2F!%40%23%24%5E%26*()%20text';
await ms(10);
expect(stateMachineRouter.currentState.params.activity).toBe(
'%+-/!@#$^&*() text'
);
});

it('should nullify query params', () => {
stateMachineRouter.emit(ACTION.goToWork);
stateMachineRouter.emit(ACTION.slack, { activity: null });
Expand Down
5 changes: 0 additions & 5 deletions packages/url-persistence/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,7 @@ const deserialize = (params, serializers: ISerializers | undefined): object => {
throw new Error(err);
}
} else {
try {
paramsObject[key] = decodeURIComponent(params[key]);
} catch(err) {
paramsObject[key] = params[key]
}

}
});
return paramsObject;
Expand Down

0 comments on commit 5aab429

Please sign in to comment.