Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Update CASE_SENSITIVE_DOMAINS

Steven Tey025c8e04392d
diff --git a/apps/web/lib/api/links/case-sensitivity.ts b/apps/web/lib/api/links/case-sensitivity.ts
index c8d5c17a35..6cf585b5ba 100644
--- a/apps/web/lib/api/links/case-sensitivity.ts
+++ b/apps/web/lib/api/links/case-sensitivity.ts
@@ -1,11 +1,12 @@
// This is not actually a secret key, it's just a string that we XOR with the key to make it case sensitive
-const SECRET_KEY = "58ff90c0dc372ded858cbf8fb2306066";
+const XOR_SECRET_KEY = "58ff90c0dc372ded858cbf8fb2306066";
export const CASE_SENSITIVE_DOMAINS = [
"buff.ly",
"dub-internal-test.com",
"go.homeserve.fr",
"go.homeserve.be",
+ "jbbr.pro",
];
export const encodeKey = (text: string): string => {
@@ -15,7 +16,8 @@ export const encodeKey = (text: string): string => {
.split("")
.map((char, i) =>
String.fromCharCode(
- char.charCodeAt(0) ^ SECRET_KEY.charCodeAt(i % SECRET_KEY.length),
+ char.charCodeAt(0) ^
+ XOR_SECRET_KEY.charCodeAt(i % XOR_SECRET_KEY.length),
),
)
.join("");
@@ -32,7 +34,8 @@ export const decodeKey = (hash: string): string => {
.split("")
.map((char, i) =>
String.fromCharCode(
- char.charCodeAt(0) ^ SECRET_KEY.charCodeAt(i % SECRET_KEY.length),
+ char.charCodeAt(0) ^
+ XOR_SECRET_KEY.charCodeAt(i % XOR_SECRET_KEY.length),
),
)
.join("");
diff --git a/apps/web/lib/middleware/link.ts b/apps/web/lib/middleware/link.ts
index 32b07fcdd2..8ac9c50d60 100644
--- a/apps/web/lib/middleware/link.ts
+++ b/apps/web/lib/middleware/link.ts
@@ -45,10 +45,6 @@ export default async function LinkMiddleware(
return NextResponse.next();
}
- if (domain === "dev.buff.ly") {
- domain = "buff.ly";
- }
-
// encode the key to ascii
// links on Dub are case insensitive by default
let key = punyEncode(originalKey);
diff --git a/apps/web/scripts/convert-case-sensitive.ts b/apps/web/scripts/convert-case-sensitive.ts
index 1156f67988..aa6e28ea74 100644
--- a/apps/web/scripts/convert-case-sensitive.ts
+++ b/apps/web/scripts/convert-case-sensitive.ts
@@ -1,7 +1,6 @@
import { prisma } from "@dub/prisma";
import { linkConstructorSimple } from "@dub/utils";
import "dotenv-flow/config";
-import { linkCache } from "../lib/api/links/cache";
import { encodeKeyIfCaseSensitive } from "../lib/api/links/case-sensitivity";
// script to convert existing links for a domain to case sensitive (encoded) setup
@@ -10,6 +9,10 @@ async function main() {
where: {
domain: "domain.com",
},
+ orderBy: {
+ createdAt: "desc",
+ },
+ take: 100,
});
await Promise.all(
@@ -35,9 +38,6 @@ async function main() {
);
}),
);
-
- const res = await linkCache.expireMany(links);
- console.log(res);
}
main();