diff --git a/platforms/cloudflare.ts b/platforms/cloudflare.ts index 19e25f1b..c62e4920 100644 --- a/platforms/cloudflare.ts +++ b/platforms/cloudflare.ts @@ -58,22 +58,19 @@ export class Redis extends core.Redis { console.warn( `[Upstash Redis] The 'url' property is missing or undefined in your Redis config.` ); - } - - if (!config.token) { + } else if (config.url.startsWith(" ") || config.url.endsWith(" ") || /\r|\n/.test(config.url)) { console.warn( - `[Upstash Redis] The 'token' property is missing or undefined in your Redis config.` + "[Upstash Redis] The redis url contains whitespace or newline, which can cause errors!" ); } - if (config.url!.startsWith(" ") || config.url!.endsWith(" ") || /\r|\n/.test(config.url!)) { + if (!config.token) { console.warn( - "[Upstash Redis] The redis url contains whitespace or newline, which can cause errors!" + `[Upstash Redis] The 'token' property is missing or undefined in your Redis config.` ); - } - if ( - config.token!.startsWith(" ") || - config.token!.endsWith(" ") || + } else if ( + config.token.startsWith(" ") || + config.token.endsWith(" ") || /\r|\n/.test(config.token!) ) { console.warn( diff --git a/platforms/fastly.ts b/platforms/fastly.ts index 279e4577..59435174 100644 --- a/platforms/fastly.ts +++ b/platforms/fastly.ts @@ -56,23 +56,20 @@ export class Redis extends core.Redis { console.warn( `[Upstash Redis] The 'url' property is missing or undefined in your Redis config.` ); - } - - if (!config.token) { + } else if (config.url.startsWith(" ") || config.url.endsWith(" ") || /\r|\n/.test(config.url)) { console.warn( - `[Upstash Redis] The 'token' property is missing or undefined in your Redis config.` + "[Upstash Redis] The redis url contains whitespace or newline, which can cause errors!" ); } - if (config.url!.startsWith(" ") || config.url!.endsWith(" ") || /\r|\n/.test(config.url!)) { + if (!config.token) { console.warn( - "[Upstash Redis] The redis url contains whitespace or newline, which can cause errors!" + `[Upstash Redis] The 'token' property is missing or undefined in your Redis config.` ); - } - if ( - config.token!.startsWith(" ") || - config.token!.endsWith(" ") || - /\r|\n/.test(config.token!) + } else if ( + config.token.startsWith(" ") || + config.token.endsWith(" ") || + /\r|\n/.test(config.token) ) { console.warn( "[Upstash Redis] The redis token contains whitespace or newline, which can cause errors!" diff --git a/platforms/nodejs.ts b/platforms/nodejs.ts index 3e3b1840..1387d726 100644 --- a/platforms/nodejs.ts +++ b/platforms/nodejs.ts @@ -105,27 +105,24 @@ export class Redis extends core.Redis { console.warn( `[Upstash Redis] The 'url' property is missing or undefined in your Redis config.` ); - } - - if (!configOrRequester.token) { + } else if ( + configOrRequester.url.startsWith(" ") || + configOrRequester.url.endsWith(" ") || + /\r|\n/.test(configOrRequester.url) + ) { console.warn( - `[Upstash Redis] The 'token' property is missing or undefined in your Redis config.` + "[Upstash Redis] The redis url contains whitespace or newline, which can cause errors!" ); } - if ( - configOrRequester.url!.startsWith(" ") || - configOrRequester.url!.endsWith(" ") || - /\r|\n/.test(configOrRequester.url!) - ) { + if (!configOrRequester.token) { console.warn( - "[Upstash Redis] The redis url contains whitespace or newline, which can cause errors!" + `[Upstash Redis] The 'token' property is missing or undefined in your Redis config.` ); - } - if ( - configOrRequester.token!.startsWith(" ") || - configOrRequester.token!.endsWith(" ") || - /\r|\n/.test(configOrRequester.token!) + } else if ( + configOrRequester.token.startsWith(" ") || + configOrRequester.token.endsWith(" ") || + /\r|\n/.test(configOrRequester.token) ) { console.warn( "[Upstash Redis] The redis token contains whitespace or newline, which can cause errors!"