The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
add go.homeserve.fr and go.homeserve.be to CASE_SENSITIVE_DOMAINS
Steven Tey31809fd128c3
diff --git a/apps/web/lib/api/links/case-sensitivity.ts b/apps/web/lib/api/links/case-sensitivity.tsindex 32f1201c28..c8d5c17a35 100644--- a/apps/web/lib/api/links/case-sensitivity.ts+++ b/apps/web/lib/api/links/case-sensitivity.ts@@ -1,7 +1,12 @@// This is not actually a secret key, it's just a string that we XOR with the key to make it case sensitiveconst SECRET_KEY = "58ff90c0dc372ded858cbf8fb2306066";-export const CASE_SENSITIVE_DOMAINS = ["buff.ly", "dub-internal-test.com"];+export const CASE_SENSITIVE_DOMAINS = [+ "buff.ly",+ "dub-internal-test.com",+ "go.homeserve.fr",+ "go.homeserve.be",+];export const encodeKey = (text: string): string => {if (!text) return "";diff --git a/apps/web/scripts/convert-case-sensitive.ts b/apps/web/scripts/convert-case-sensitive.tsnew file mode 100644index 0000000000..1156f67988--- /dev/null+++ b/apps/web/scripts/convert-case-sensitive.ts@@ -0,0 +1,43 @@+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+async function main() {+ const links = await prisma.link.findMany({+ where: {+ domain: "domain.com",+ },+ });++ await Promise.all(+ links.map(async (link) => {+ const newKey = encodeKeyIfCaseSensitive({+ domain: link.domain,+ key: link.key,+ });++ const newLink = await prisma.link.update({+ where: { id: link.id },+ data: {+ key: newKey,+ shortLink: linkConstructorSimple({+ domain: link.domain,+ key: newKey,+ }),+ },+ });++ console.log(+ `Updated link ${link.id} from key ${link.key} to ${newLink.key} (shortLink: ${newLink.shortLink})`,+ );+ }),+ );++ const res = await linkCache.expireMany(links);+ console.log(res);+}++main();