Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion mod.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HttpClient } from "./pkg/http.ts";
import * as core from "./pkg/redis.ts";
export type { Requester, UpstashRequest, UpstashResponse } from "./pkg/http";
export type { Requester, UpstashRequest, UpstashResponse } from "./pkg/http.ts";

/**
* Connection credentials for upstash redis.
Expand Down Expand Up @@ -33,6 +33,25 @@ export class Redis extends core.Redis {
* ```
*/
constructor(config: RedisConfigDeno) {
if (
config.url.startsWith(" ") ||
config.url.endsWith(" ") ||
/\r|\n/.test(config.url)
) {
console.warn(
"The redis url contains whitespace or newline, which can cause errors!",
);
}
if (
config.token.startsWith(" ") ||
config.token.endsWith(" ") ||
/\r|\n/.test(config.token)
) {
console.warn(
"The redis token contains whitespace or newline, which can cause errors!",
);
}

const client = new HttpClient({
baseUrl: config.url,
headers: { authorization: `Bearer ${config.token}` },
Expand Down
18 changes: 18 additions & 0 deletions platforms/cloudflare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,24 @@ export class Redis extends core.Redis {
* ```
*/
constructor(config: RedisConfigCloudflare) {
if (
config.url.startsWith(" ") ||
config.url.endsWith(" ") ||
/\r|\n/.test(config.url)
) {
console.warn(
"The redis url contains whitespace or newline, which can cause errors!",
);
}
if (
config.token.startsWith(" ") ||
config.token.endsWith(" ") ||
/\r|\n/.test(config.token)
) {
console.warn(
"The redis token contains whitespace or newline, which can cause errors!",
);
}
const client = defaultRequester({
baseUrl: config.url,
headers: { authorization: `Bearer ${config.token}` },
Expand Down
18 changes: 18 additions & 0 deletions platforms/fastly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,24 @@ export class Redis extends core.Redis {
* ```
*/
constructor(config: RedisConfigFastly) {
if (
config.url.startsWith(" ") ||
config.url.endsWith(" ") ||
/\r|\n/.test(config.url)
) {
console.warn(
"The redis url contains whitespace or newline, which can cause errors!",
);
}
if (
config.token.startsWith(" ") ||
config.token.endsWith(" ") ||
/\r|\n/.test(config.token)
) {
console.warn(
"The redis token contains whitespace or newline, which can cause errors!",
);
}
const client = defaultRequester({
baseUrl: config.url,
headers: { authorization: `Bearer ${config.token}` },
Expand Down
18 changes: 18 additions & 0 deletions platforms/nodejs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,24 @@ export class Redis extends core.Redis {
super(configOrRequester);
return;
}
if (
configOrRequester.url.startsWith(" ") ||
configOrRequester.url.endsWith(" ") ||
/\r|\n/.test(configOrRequester.url)
) {
console.warn(
"The redis url contains whitespace or newline, which can cause errors!",
);
}
if (
configOrRequester.token.startsWith(" ") ||
configOrRequester.token.endsWith(" ") ||
/\r|\n/.test(configOrRequester.token)
) {
console.warn(
"The redis token contains whitespace or newline, which can cause errors!",
);
}

const client = defaultRequester({
baseUrl: configOrRequester.url,
Expand Down