Make parseRedirect more resilient.
This commit is contained in:
parent
aa9a7121f8
commit
2ca4aeefb7
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ test('parseRedirect', (t) => {
|
|||
{
|
||||
test: 'Invalid parameters',
|
||||
} as unknown as Redirects['parameters'],
|
||||
undefined as unknown as Redirects['parameters'],
|
||||
hostnameParameters,
|
||||
];
|
||||
|
||||
|
|
Loading…
Reference in New Issue