diff --git a/src/utils/is-redirect-status-code.ts b/src/utils/is-redirect-status-code.ts index 7c373e2b6..728d21769 100644 --- a/src/utils/is-redirect-status-code.ts +++ b/src/utils/is-redirect-status-code.ts @@ -1,5 +1,8 @@ const REDIRECT_STATUS_CODES = [301, 302, 303, 307, 308]; -export default function (code: number): boolean { +export default function (code?: number): boolean { + if (!code) + return false; + return REDIRECT_STATUS_CODES.includes(code); } diff --git a/ts-defs/index.d.ts b/ts-defs/index.d.ts index 6d414b4bf..ca5be371f 100644 --- a/ts-defs/index.d.ts +++ b/ts-defs/index.d.ts @@ -592,7 +592,7 @@ declare module 'testcafe-hammerhead' { function getAssetPath(originPath: string, developmentMode: boolean): string; /** Return whether the HTTP status code is a redirect status code **/ - function isRedirectStatusCode (code: number): boolean; + function isRedirectStatusCode (code?: number): boolean; /** **/ export class IncomingMessageLike {