Skip to content

Commit e9de584

Browse files
Denperidgejtojnar
authored andcommitted
client: uri.ts error catches
1 parent e2b2f50 commit e9de584

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

client/js/helpers/uri.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ export function filterTypeToString(type: FilterType): string {
4747
return 'unread';
4848
} else if (type == FilterType.STARRED) {
4949
return 'starred';
50+
} else {
51+
throw new Error(`Invalid filter type: “${type}”`);
5052
}
5153
}
5254

@@ -70,6 +72,13 @@ export function useEntriesParams(): Params | null {
7072
}
7173

7274
const { params } = match;
75+
76+
if (!params.filter || !params.category) {
77+
// Note: it isn't possible to reach this part of the code
78+
// This is to keep the TypeScript compiler happy
79+
return null;
80+
}
81+
7382
const filterValid = /^(newest|unread|starred)$/.test(params.filter);
7483
const categoryValid = /^(all|tag-.+|source-[0-9]+)$/.test(params.category);
7584
const idValid = params.id === undefined || /^\d+$/.test(params.id);

0 commit comments

Comments
 (0)