Make parseRedirect more resilient.

This commit is contained in:
Bauke 2022-10-13 00:30:26 +02:00
parent aa9a7121f8
commit 2ca4aeefb7
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
2 changed files with 2 additions and 1 deletions

View File

@ -8,7 +8,7 @@ export type Redirects = HostnameRedirect;
export function parseRedirect<P extends Redirects['parameters']>(
parameters: P,
): Redirects | undefined {
if (parameters.type === 'hostname') {
if (parameters?.type === 'hostname') {
return new HostnameRedirect(parameters);
}
}

View File

@ -22,6 +22,7 @@ test('parseRedirect', (t) => {
{
test: 'Invalid parameters',
} as unknown as Redirects['parameters'],
undefined as unknown as Redirects['parameters'],
hostnameParameters,
];