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']>(
|
export function parseRedirect<P extends Redirects['parameters']>(
|
||||||
parameters: P,
|
parameters: P,
|
||||||
): Redirects | undefined {
|
): Redirects | undefined {
|
||||||
if (parameters.type === 'hostname') {
|
if (parameters?.type === 'hostname') {
|
||||||
return new HostnameRedirect(parameters);
|
return new HostnameRedirect(parameters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ test('parseRedirect', (t) => {
|
||||||
{
|
{
|
||||||
test: 'Invalid parameters',
|
test: 'Invalid parameters',
|
||||||
} as unknown as Redirects['parameters'],
|
} as unknown as Redirects['parameters'],
|
||||||
|
undefined as unknown as Redirects['parameters'],
|
||||||
hostnameParameters,
|
hostnameParameters,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue