The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
added some more changes, renamed hostname to domain (standardized naming)
Steven Tey5bce41ba75e5
diff --git a/README.md b/README.mdindex be1f92e48b..e3ff7d76a2 100644--- a/README.md+++ b/README.md@@ -71,7 +71,7 @@ Dub is built as a standard Next.js application with [Middleware](https://nextjs.- `{domain}:{key}` – string containing a JSON object with the target URL and password (optional). Also has an optional TTL.- `{domain}:clicks:{key}` – sorted set of all clicks for a given link (e.g. `dub.sh:clicks:github`)-- `{domain}:root:clicks` – sorted set of all root link clicks for a given hostname (e.g. `dub.sh:root:clicks`)+- `{domain}:root:clicks` – sorted set of all root link clicks for a given domain (e.g. `dub.sh:root:clicks`)[MySQL](https://www.mysql.com/) is used as the database for storing user data, project data, and link metadata. You can refer to the Prisma schema [here](/prisma/schema.prisma).diff --git a/components/app/modals/add-edit-link-modal.tsx b/components/app/modals/add-edit-link-modal.tsxindex 0b7cd669c7..30677aaded 100644--- a/components/app/modals/add-edit-link-modal.tsx+++ b/components/app/modals/add-edit-link-modal.tsx@@ -276,12 +276,18 @@ function AddEditLinkModal({);}-function AdvancedSettings({ data, setData }) {- const [expanded, setExpanded] = useState(false);+function AdvancedSettings({+ data,+ setData,+}: {+ data: LinkProps;+ setData: Dispatch<SetStateAction<LinkProps>>;+}) {+ const [expanded, setExpanded] = useState(true);const [generatingTitle, setGeneratingTitle] = useState(false);const [generatingDescription, setGeneratingDescription] = useState(false);- const { url, title, description, image } = data;+ const { url, title, description, image, password } = data;const generateTitleFromUrl = async () => {setGeneratingTitle(true);@@ -310,7 +316,7 @@ function AdvancedSettings({ data, setData }) {const file = e.target.files[0];const reader = new FileReader();reader.onload = (e) => {- setData((prev) => ({ ...prev, image: e.target.result }));+ setData((prev) => ({ ...prev, image: e.target.result as string }));};reader.readAsDataURL(file);},@@ -336,6 +342,7 @@ function AdvancedSettings({ data, setData }) {{expanded && (<div className="mt-4 grid gap-5 bg-white border-t border-b border-gray-200 sm:px-16 px-4 py-8">+ {/* OG Tags */}<div><div className="flex justify-between items-center"><label@@ -424,18 +431,18 @@ function AdvancedSettings({ data, setData }) {className="group flex flex-col justify-center items-center mt-1 h-[10.5rem] cursor-pointer rounded-md border border-gray-300 bg-white hover:bg-gray-50 shadow-sm transition-all">{image ? (- image.startsWith("data:") ? (- <img+ typeof image === "string" ? (+ <BlurImagesrc={image}alt="Preview"+ width={1200}+ height={627}className="object-cover h-full w-full rounded-md hover:brightness-95 transition-all"/>) : (- <BlurImage+ <imgsrc={image}alt="Preview"- width={1200}- height={627}className="object-cover h-full w-full rounded-md hover:brightness-95 transition-all"/>)@@ -459,6 +466,29 @@ function AdvancedSettings({ data, setData }) {/></div></div>++ {/* Password Protection */}+ <div>+ <label+ htmlFor="password"+ className="block text-sm font-medium text-gray-700"+ >+ Password Protection+ </label>+ <div className="flex mt-1 rounded-md shadow-sm">+ <input+ name="password"+ id="password"+ type="password"+ className="border-gray-300 text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:ring-gray-500 block w-full rounded-md focus:outline-none sm:text-sm"+ value={password}+ onChange={(e) => {+ setData({ ...data, password: e.target.value });+ }}+ aria-invalid="true"+ />+ </div>+ </div></div>)}</div>diff --git a/components/home/globe.tsx b/components/home/globe.tsxindex 97eff5d163..5cad87ee31 100644--- a/components/home/globe.tsx+++ b/components/home/globe.tsx@@ -13,7 +13,7 @@ interface MarkerProps {size: number;}-export default function Globe({ hostname }: { hostname?: string }) {+export default function Globe({ domain }: { domain?: string }) {const divRef = useRef<any>();const entry = useIntersectionObserver(divRef, {});const isVisible = !!entry?.isIntersecting;@@ -48,14 +48,14 @@ export default function Globe({ hostname }: { hostname?: string }) {}, []);const { data: markers } = useSWR<MarkerProps[]>(- `/api/edge/coordinates${hostname ? `?hostname=${hostname}` : ""}`,+ `/api/edge/coordinates${domain ? `?domain=${domain}` : ""}`,fetcher,);return (<div ref={divRef} className="h-full min-h-[500px] sm:min-h-[1000px]">{webglSupported && showGlobe && (- <GlobeAnimation hostname={hostname} markers={markers} />+ <GlobeAnimation domain={domain} markers={markers} />)}{showFallback && (<div className="w-full h-full flex items-center justify-center">@@ -75,10 +75,10 @@ export default function Globe({ hostname }: { hostname?: string }) {}const GlobeAnimation = ({- hostname,+ domain,markers,}: {- hostname?: string;+ domain?: string;markers: MarkerProps[];}) => {const canvasRef = useRef<any>();@@ -160,17 +160,15 @@ const GlobeAnimation = ({This map shows the locations of the last 100 clicks on{" "}<aclassName="text-blue-800 font-semibold"- href={- hostname ? `https://${hostname}` : "https://dub.sh/github"- }+ href={domain ? `https://${domain}` : "https://dub.sh/github"}target="_blank"rel="noreferrer">- {hostname || "dub.sh/github"}+ {domain || "dub.sh/github"}</a>{" "}in real time.</p>- {!hostname && (+ {!domain && (<Linkhref={{ pathname: "/", query: { key: "github" } }}as="/stats/github"diff --git a/lib/api/links.ts b/lib/api/links.tsindex 774e191aab..77e7507277 100644--- a/lib/api/links.ts+++ b/lib/api/links.ts@@ -46,17 +46,9 @@ export async function checkIfKeyExists(domain: string, key: string) {}export async function addLink(link: LinkProps) {- const {- domain,- key,- url,- expiresAt,- passwordHash,- title,- description,- image,- } = link;- const password = passwordHash ? true : false;+ const { domain, key, url, expiresAt, password, title, description, image } =+ link;+ const hasPassword = password && password.length > 0;const proxy = title && description && image ? true : false;const exat = expiresAt ? expiresAt.getTime() : null;@@ -75,7 +67,7 @@ export async function addLink(link: LinkProps) {`${domain}:${key}`,{url,- password,+ password: hasPassword,proxy,},{@@ -115,12 +107,12 @@ export async function editLink(key,url,expiresAt,- passwordHash,+ password,title,description,image,} = link;- const password = passwordHash ? true : false;+ const hasPassword = password && password.length > 0;const proxy = title && description && image ? true : false;const exat = expiresAt ? expiresAt.getTime() : null;const changedKey = key !== oldKey;@@ -154,7 +146,7 @@ export async function editLink(`${domain}:${key}`,{url,- password,+ password: hasPassword,proxy,},{diff --git a/lib/middleware/link.ts b/lib/middleware/link.tsindex 165e30d179..121b4143a9 100644--- a/lib/middleware/link.ts+++ b/lib/middleware/link.ts@@ -8,9 +8,9 @@ export default async function LinkMiddleware(ev: NextFetchEvent,) {const url = req.nextUrl.clone();- const { hostname, key } = parse(req);+ const { domain, key } = parse(req);- if (!hostname || !key) {+ if (!domain || !key) {return NextResponse.next();}@@ -18,25 +18,29 @@ export default async function LinkMiddleware(url: string;password?: boolean;proxy?: boolean;- }>(`${hostname}:${key}`);+ }>(`${domain}:${key}`);const { url: target, password, proxy } = response || {};console.log(req.cookies.get("dub_authenticated"));if (target) {if (password && !req.cookies.get("dub_authenticated")) {- return NextResponse.rewrite(`https://dub.sh/auth/${hostname}/${key}`);+ return NextResponse.rewrite(+ process.env.NODE_ENV === "development"+ ? `http://localhost:3000/auth/${domain}/${key}`+ : `https://dub.sh/auth/${domain}/${key}`,+ );}// special case for link health monitoring with planetfall.io :)if (!req.headers.get("dub-no-track")) {- ev.waitUntil(recordClick(hostname, req, key)); // track the click only if there is no `dub-no-track` header+ ev.waitUntil(recordClick(domain, req, key)); // track the click only if there is no `dub-no-track` header}const isBot = detectBot(req);- if (isBot) {+ if (isBot && proxy) {// rewrite to proxy page (dub.sh/proxy/[domain]/[key]) if it's a bot- return NextResponse.rewrite(`https://dub.sh/proxy/${hostname}/${key}`);+ return NextResponse.rewrite(`https://dub.sh/proxy/${domain}/${key}`);} else {return NextResponse.redirect(target);}diff --git a/lib/middleware/root.ts b/lib/middleware/root.tsindex 3295734f8a..13c106a29a 100644--- a/lib/middleware/root.ts+++ b/lib/middleware/root.ts@@ -6,35 +6,35 @@ export default async function RootMiddleware(req: NextRequest,ev: NextFetchEvent,) {- const { hostname } = parse(req);+ const { domain } = parse(req);- if (!hostname) {+ if (!domain) {return NextResponse.next();}if (- hostname === "dub.sh" ||- hostname === "preview.dub.sh" ||- hostname.endsWith(".vercel.app")+ domain === "dub.sh" ||+ domain === "preview.dub.sh" ||+ domain.endsWith(".vercel.app")) {ev.waitUntil(redis.incr("dub.sh:root:clicks")); // increment root clicks (only for dub.sh)} else {- ev.waitUntil(recordClick(hostname, req)); // record clicks on root page (if hostname is not dub.sh)+ ev.waitUntil(recordClick(domain, req)); // record clicks on root page (if domain is not dub.sh)}if (- hostname === "dub.sh" ||- hostname === "preview.dub.sh" ||- hostname.endsWith(".vercel.app")+ domain === "dub.sh" ||+ domain === "preview.dub.sh" ||+ domain.endsWith(".vercel.app")) {return NextResponse.next();} else {- const target = await redis.get<string>(`root:${hostname}`);+ const target = await redis.get<string>(`root:${domain}`);if (target) {return NextResponse.redirect(target);} else {const url = req.nextUrl;- url.pathname = `/placeholder/${hostname}`; // rewrite to a /placeholder page unless the user defines a site to redirect to+ url.pathname = `/placeholder/${domain}`; // rewrite to a /placeholder page unless the user defines a site to redirect toreturn NextResponse.rewrite(url);}}diff --git a/lib/middleware/utils.ts b/lib/middleware/utils.tsindex 04fe53ac65..1e07570b05 100644--- a/lib/middleware/utils.ts+++ b/lib/middleware/utils.ts@@ -2,11 +2,11 @@ import { NextRequest } from "next/server";import { HOME_HOSTNAMES } from "@/lib/constants";export const parse = (req: NextRequest) => {- let hostname = req.headers.get("host");- if (HOME_HOSTNAMES.has(hostname)) hostname = "dub.sh";+ let domain = req.headers.get("host");+ if (HOME_HOSTNAMES.has(domain)) domain = "dub.sh";const path = req.nextUrl.pathname;const key = decodeURIComponent(path.split("/")[1]); // to handle foreign languages like Hebrew- return { hostname, path, key };+ return { domain, path, key };};export const detectBot = (req: NextRequest) => {diff --git a/lib/types.ts b/lib/types.tsindex 257f5a0410..ced48cf1a2 100644--- a/lib/types.ts+++ b/lib/types.ts@@ -10,7 +10,7 @@ export interface LinkProps {url: string;archived: boolean;expiresAt?: Date;- passwordHash?: string;+ password?: string;title?: string;description?: string;diff --git a/lib/upstash.ts b/lib/upstash.tsindex 9c9bf54362..6b1ec442ee 100644--- a/lib/upstash.ts+++ b/lib/upstash.ts@@ -36,14 +36,14 @@ const nanoid = customAlphabet(); // 7-character random stringexport async function setKey(- hostname: string,+ domain: string,key: string,url: string,title?: string,description?: string, // only for Pro users: customize descriptionimage?: string, // only for Pro users: customize OG image) {- return await redis.hsetnx(`${hostname}:links`, key, {+ return await redis.hsetnx(`${domain}:links`, key, {url,title: title || (await getTitleFromUrl(url)),description:@@ -54,38 +54,38 @@ export async function setKey(}export async function setRandomKey(- hostname: string,+ domain: string,url: string,title?: string,): Promise<{ response: number; key: string }> {/* recursively set link till successful */const key = nanoid();- const response = await setKey(hostname, key, url, title); // add to hash+ const response = await setKey(domain, key, url, title); // add to hashif (response === 0) {// by the off chance that key already exists- return setRandomKey(hostname, url, title);+ return setRandomKey(domain, url, title);} else {return { response, key };}}-export async function getRandomKey(hostname: string): Promise<string> {+export async function getRandomKey(domain: string): Promise<string> {/* recursively get random key till it gets one that's avaialble */const key = nanoid();- const response = await redis.hexists(`${hostname}:links`, key); // check if key exists+ const response = await redis.hexists(`${domain}:links`, key); // check if key existsif (response === 1) {// by the off chance that key already exists- return getRandomKey(hostname);+ return getRandomKey(domain);} else {return key;}}-export async function checkIfKeyExists(hostname: string, key: string) {- if (hostname === "dub.sh" && RESERVED_KEYS.has(key)) {+export async function checkIfKeyExists(domain: string, key: string) {+ if (domain === "dub.sh" && RESERVED_KEYS.has(key)) {return 1; // reserved keys for dub.sh}- return await redis.hexists(`${hostname}:links`, key);+ return await redis.hexists(`${domain}:links`, key);}/**@@ -93,12 +93,12 @@ export async function checkIfKeyExists(hostname: string, key: string) {* If key is not specified, record click as the root click**/export async function recordClick(- hostname: string,+ domain: string,req: NextRequest,key?: string,) {return await redis.zadd(- key ? `${hostname}:clicks:${key}` : `${hostname}:root:clicks`,+ key ? `${domain}:clicks:${key}` : `${domain}:root:clicks`,{score: Date.now(),member: {@@ -159,7 +159,7 @@ export async function getLinkClicksCount(domain: string, key: string) {}export async function addLink(- hostname: string,+ domain: string,link: LinkProps,userId?: string, // only applicable for dub.sh links) {@@ -171,16 +171,16 @@ export async function addLink(image, // only for Pro users: customize OG image} = link;- if (hostname === "dub.sh" && key && RESERVED_KEYS.has(key)) {+ if (domain === "dub.sh" && key && RESERVED_KEYS.has(key)) {return null; // reserved keys for dub.sh}const response = key- ? await setKey(hostname, key, url, title, description, image)- : await setRandomKey(hostname, url, title); // not possible to add description and image for random keys (only for dub.sh landing page input)+ ? await setKey(domain, key, url, title, description, image)+ : await setRandomKey(domain, url, title); // not possible to add description and image for random keys (only for dub.sh landing page input)if (response === 1) {return await redis.zadd(- `${hostname}:links:timestamps${userId ? `:${userId}` : ""}`,+ `${domain}:links:timestamps${userId ? `:${userId}` : ""}`,{score: Date.now(),member: key,@@ -195,19 +195,19 @@ export async function addLink(* Get the usage for a project**/export async function getUsage(- hostname: string,+ domain: string,billingCycleStart: number,): Promise<number> {const { firstDay, lastDay } = getFirstAndLastDay(billingCycleStart);- const links = await redis.zrange(`${hostname}:links:timestamps`, 0, -1);+ const links = await redis.zrange(`${domain}:links:timestamps`, 0, -1);let results: number[] = [];if (links.length > 0) {const pipeline = redis.pipeline();links.forEach((link) => {pipeline.zcount(- `${hostname}:clicks:${link}`,+ `${domain}:clicks:${link}`,firstDay.getTime(),lastDay.getTime(),);@@ -218,24 +218,21 @@ export async function getUsage(return usage;}-export async function changeDomain(hostname: string, newHostname: string) {+export async function changeDomain(domain: string, newHostname: string) {const keys = await redis.zrange<string[]>(- `${hostname}:links:timestamps`,+ `${domain}:links:timestamps`,0,-1,);const pipeline = redis.pipeline();- pipeline.rename(`${hostname}:links`, `${newHostname}:links`);+ pipeline.rename(`${domain}:links`, `${newHostname}:links`);pipeline.rename(- `${hostname}:links:timestamps`,+ `${domain}:links:timestamps`,`${newHostname}:links:timestamps`,);- pipeline.rename(`${hostname}:root:clicks`, `${newHostname}:root:clicks`);+ pipeline.rename(`${domain}:root:clicks`, `${newHostname}:root:clicks`);keys.forEach((key) => {- pipeline.rename(- `${hostname}:clicks:${key}`,- `${newHostname}:clicks:${key}`,- );+ pipeline.rename(`${domain}:clicks:${key}`, `${newHostname}:clicks:${key}`);});try {return await pipeline.exec();@@ -244,18 +241,18 @@ export async function changeDomain(hostname: string, newHostname: string) {}}-export async function deleteProject(hostname: string) {+export async function deleteProject(domain: string) {const keys = await redis.zrange<string[]>(- `${hostname}:links:timestamps`,+ `${domain}:links:timestamps`,0,-1,);const pipeline = redis.pipeline();- pipeline.del(`${hostname}:links`);- pipeline.del(`${hostname}:links:timestamps`);- pipeline.del(`${hostname}:root:clicks`);+ pipeline.del(`${domain}:links`);+ pipeline.del(`${domain}:links:timestamps`);+ pipeline.del(`${domain}:root:clicks`);keys.forEach((key) => {- pipeline.del(`${hostname}:clicks:${key}`);+ pipeline.del(`${domain}:clicks:${key}`);});try {return await pipeline.exec();diff --git a/middleware.ts b/middleware.tsindex 5d40070c10..bc7580f5dc 100644--- a/middleware.ts+++ b/middleware.ts@@ -25,9 +25,9 @@ export const config = {};export default async function middleware(req: NextRequest, ev: NextFetchEvent) {- const { hostname, key } = parse(req);- const home = HOME_HOSTNAMES.has(hostname);- const app = hostname === "app.dub.sh" || hostname === "app.localhost:3000";+ const { domain, key } = parse(req);+ const home = HOME_HOSTNAMES.has(domain);+ const app = domain === "app.dub.sh" || domain === "app.localhost:3000";if (app) {return AppMiddleware(req);diff --git a/package.json b/package.jsonindex 96e9c8c956..d9b399468d 100644--- a/package.json+++ b/package.json@@ -30,7 +30,6 @@"@visx/responsive": "^2.10.0","@visx/shape": "^2.12.2","@visx/tooltip": "^2.10.0",- "bcrypt": "^5.1.0","cloudinary": "^1.32.0","cobe": "^0.6.2","focus-trap-react": "^10.0.0",diff --git a/pages/api/auth/decrypt-password.ts b/pages/api/auth/decrypt-password.tsindex a84791429d..614752d439 100644--- a/pages/api/auth/decrypt-password.ts+++ b/pages/api/auth/decrypt-password.ts@@ -1,5 +1,4 @@import { NextApiRequest, NextApiResponse } from "next";-import { compare } from "bcrypt";import { serialize } from "cookie";import prisma from "@/lib/prisma";@@ -9,11 +8,11 @@ export default async function handler() {if (req.method === "POST") {const { domain, key, password } = req.body;- const { url, passwordHash } = await prisma.link.findUnique({+ const { url, password: realPassword } = await prisma.link.findUnique({where: { domain_key: { domain, key } },- select: { url: true, passwordHash: true },+ select: { url: true, password: true },});- const validPassword = await compare(password, passwordHash);+ const validPassword = password === realPassword;if (validPassword) {// Set cookie to authenticate user for 1 weekres.setHeader(diff --git a/pages/api/edge/coordinates.ts b/pages/api/edge/coordinates.tsindex 2678bdafe9..e875c24277 100644--- a/pages/api/edge/coordinates.ts+++ b/pages/api/edge/coordinates.ts@@ -9,9 +9,9 @@ export const config = {export default async function handler(req: NextRequest) {if (req.method === "GET") {const numPoints = 100;- const hostname = req.nextUrl.searchParams.get("hostname");+ const domain = req.nextUrl.searchParams.get("domain");const rawData = await redis.zrange<RawStatsProps[]>(- hostname ? `${hostname}:root:clicks` : "dub.sh:clicks:github",+ domain ? `${domain}:root:clicks` : "dub.sh:clicks:github",0,numPoints,{ rev: true },diff --git a/pages/api/edge/links/index.ts b/pages/api/edge/links/index.tsindex 28e839ec3d..83bc1ccd5c 100644--- a/pages/api/edge/links/index.ts+++ b/pages/api/edge/links/index.ts@@ -9,7 +9,7 @@ export default async function handler(req: NextRequest) {if (req.method === "POST") {const url = req.nextUrl.searchParams.get("url");if (!url) {- return new Response(`Missing url or hostname`, { status: 400 });+ return new Response(`Missing url`, { status: 400 });}const { response, key } = await setRandomKey("dub.sh", url);if (response === 1) {diff --git a/pages/api/projects/[slug]/domains/[domain]/links/count.ts b/pages/api/projects/[slug]/domains/[domain]/links/count.tsindex 27b7cc4da3..c7b8c46148 100644--- a/pages/api/projects/[slug]/domains/[domain]/links/count.ts+++ b/pages/api/projects/[slug]/domains/[domain]/links/count.ts@@ -8,7 +8,7 @@ export default withProjectAuth(if (req.method === "GET") {const { domain } = req.query as { domain: string };if (!domain) {- return res.status(400).json({ error: "Missing hostname" });+ return res.status(400).json({ error: "Missing domain" });}const count = await getLinkCountForProject(domain);return res.status(200).json(count);diff --git a/pages/api/projects/[slug]/domains/[domain]/links/random.ts b/pages/api/projects/[slug]/domains/[domain]/links/random.tsindex 201fb595e2..c682957026 100644--- a/pages/api/projects/[slug]/domains/[domain]/links/random.ts+++ b/pages/api/projects/[slug]/domains/[domain]/links/random.ts@@ -8,7 +8,7 @@ export default withProjectAuth(if (req.method === "GET") {const { domain } = req.query as { domain: string };if (!domain) {- return res.status(400).json({ error: "Missing hostname" });+ return res.status(400).json({ error: "Missing domain" });}const key = await getRandomKey(domain);return res.status(200).json(key);diff --git a/pages/placeholder/[[...domain]].tsx b/pages/placeholder/[[...domain]].tsxindex f7758241a4..1d85c000f8 100644--- a/pages/placeholder/[[...domain]].tsx+++ b/pages/placeholder/[[...domain]].tsx@@ -7,7 +7,7 @@ import MaxWidthWrapper from "@/components/shared/max-width-wrapper";export default function Placeholder({ domain }: { domain: string }) {return (<HomeLayout domain={domain}>- <Globe hostname={domain} />+ <Globe domain={domain} /></HomeLayout>);}diff --git a/pages/proxy/[domain]/[key].tsx b/pages/proxy/[domain]/[key].tsxindex c72d496f46..f7cf3ac6dc 100644--- a/pages/proxy/[domain]/[key].tsx+++ b/pages/proxy/[domain]/[key].tsx@@ -2,12 +2,10 @@ import Image from "next/future/image";import Head from "next/head";import { escape } from "html-escaper";import prisma from "@/lib/prisma";-import { LinkProps } from "@/lib/types";-import { redis } from "@/lib/upstash";import { getApexDomain } from "@/lib/utils";export default function LinkPage({- hostname,+ fullDomain,apexDomain,title,description,@@ -17,11 +15,11 @@ export default function LinkPage({<><Head><meta property="og:title" content={escape(title)} />- <meta property="og:site_name" content={escape(hostname)} />+ <meta property="og:site_name" content={escape(fullDomain)} /><meta property="og:description" content={escape(description)} /><meta property="og:image" content={escape(image)} /><meta name="twitter:card" content="summary_large_image" />- <meta name="twitter:site" content={escape(hostname)} />+ <meta name="twitter:site" content={escape(fullDomain)} /><meta name="twitter:title" content={escape(title)} /><meta name="twitter:description" content={escape(description)} /><meta name="twitter:image" content={escape(image)} />@@ -96,12 +94,12 @@ export async function getStaticProps(ctx) {};}- const hostname = new URL(url).hostname;+ const fullDomain = new URL(url).hostname;const apexDomain = getApexDomain(url);return {props: {- hostname,+ fullDomain,apexDomain,title,description,diff --git a/prisma/schema.prisma b/prisma/schema.prismaindex 72fb691230..d32e1941c0 100644--- a/prisma/schema.prisma+++ b/prisma/schema.prisma@@ -120,7 +120,7 @@ model Link {url String // target url (e.g. https://github.com/steven-tey/dub) – also stored on Redisarchived Boolean @default(false) // whether the link is archived or notexpiresAt DateTime? // when the link expires – stored on Redis via ttl- passwordHash String? // password to access the link – also stored on Redis+ password String? // password to access the link – also stored on Redis// Custom OG tags – if not set, will use OG tags from target urltitle String? // OG title for the link (e.g. Dub - Open-Source Bitly Alternative)diff --git a/yarn.lock b/yarn.lockindex 1cfc9c9def..732e99fb81 100644--- a/yarn.lock+++ b/yarn.lock@@ -366,21 +366,6 @@resolved "https://registry.npmjs.org/@juggle/resize-observer/-/resize-observer-3.4.0.tgz"integrity sha512-dfLbk+PwWvFzSxwk3n5ySL0hfBog779o8h68wK/7/APo/7cgyWp5jcXockbxdk5kFRkbeXWm4Fbi9FrdN381sA==-"@mapbox/node-pre-gyp@^1.0.10":- version "1.0.10"- resolved "https://registry.yarnpkg.com/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.10.tgz#8e6735ccebbb1581e5a7e652244cadc8a844d03c"- integrity sha512-4ySo4CjzStuprMwk35H5pPbkymjv1SF3jGLj6rAHp/xT/RF7TL7bd9CTm1xDY49K2qF7jmR/g7k+SkLETP6opA==- dependencies:- detect-libc "^2.0.0"- https-proxy-agent "^5.0.0"- make-dir "^3.1.0"- node-fetch "^2.6.7"- nopt "^5.0.0"- npmlog "^5.0.1"- rimraf "^3.0.2"- semver "^7.3.5"- tar "^6.1.11"-"@motionone/animation@^10.13.1":version "10.14.0"resolved "https://registry.npmjs.org/@motionone/animation/-/animation-10.14.0.tgz"@@ -1709,14 +1694,6 @@ archy@~1.0.0:resolved "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz"integrity sha512-Xg+9RwCg/0p32teKdGMPTPnVXKD0w3DfHnFTficozsAgsvq2XenPJq/MYpzzQ/v8zrOyJn6Ds39VA4JIDwFfqw==-are-we-there-yet@^2.0.0:- version "2.0.0"- resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-2.0.0.tgz#372e0e7bd279d8e94c653aaa1f67200884bf3e1c"- integrity sha512-Ci/qENmwHnsYo9xKIcUJN5LeDKdJ6R1Z1j9V/J5wyq8nh/mYPEpIKJbBZXtZjG04HiK7zV/p6Vs9952MrMeUIw==- dependencies:- delegates "^1.0.0"- readable-stream "^3.6.0"-are-we-there-yet@^3.0.0:version "3.0.1"resolved "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-3.0.1.tgz"@@ -1797,14 +1774,6 @@ balanced-match@^1.0.0:resolved "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz"integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==-bcrypt@^5.1.0:- version "5.1.0"- resolved "https://registry.yarnpkg.com/bcrypt/-/bcrypt-5.1.0.tgz#bbb27665dbc400480a524d8991ac7434e8529e17"- integrity sha512-RHBS7HI5N5tEnGTmtR/pppX0mmDSBpQ4aCBsj7CEQfYXDcO74A8sIBYcJMuCsis2E81zDxeENYhv66oZwLiA+Q==- dependencies:- "@mapbox/node-pre-gyp" "^1.0.10"- node-addon-api "^5.0.0"-big-integer@^1.6.17:version "1.6.51"resolved "https://registry.yarnpkg.com/big-integer/-/big-integer-1.6.51.tgz#0df92a5d9880560d3ff2d5fd20245c889d130686"@@ -2194,7 +2163,7 @@ color-string@^1.6.0:color-name "^1.0.0"simple-swizzle "^0.2.2"-color-support@^1.1.2, color-support@^1.1.3:+color-support@^1.1.3:version "1.1.3"resolved "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz"integrity sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==@@ -2255,7 +2224,7 @@ config-chain@^1.1.13:ini "^1.3.4"proto-list "~1.2.1"-console-control-strings@^1.0.0, console-control-strings@^1.1.0:+console-control-strings@^1.1.0:version "1.1.0"resolved "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz"integrity sha512-ty/fTekppD2fIwRvnZAVdeOiGd1c7YXEixbgJTNzqcxJWKQnjJ/V1bNEEE6hygpM3WjwHFUVK6HTjWSzV4a8sQ==@@ -2500,11 +2469,6 @@ depd@^1.1.2:resolved "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz"integrity sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==-detect-libc@^2.0.0:- version "2.0.1"- resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-2.0.1.tgz#e1897aa88fa6ad197862937fbc0441ef352ee0cd"- integrity sha512-463v3ZeIrcWtdgIg6vI6XUncguvr2TnGl4SzDXinkt9mSLpBJKXT3mW6xT3VQdDN11+WVs29pgvivTc4Lp8v+w==-version "2.0.4"resolved "https://registry.yarnpkg.com/detect-node/-/detect-node-2.0.4.tgz#014ee8f8f669c5c58023da64b8179c083a28c46c"@@ -3034,21 +2998,6 @@ function-bind@^1.1.1:resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz"integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==-gauge@^3.0.0:- version "3.0.2"- resolved "https://registry.yarnpkg.com/gauge/-/gauge-3.0.2.tgz#03bf4441c044383908bcfa0656ad91803259b395"- integrity sha512-+5J6MS/5XksCuXq++uFRsnUd7Ovu1XenbeuIuNRJxYWjgQbPuFhT14lAvsWfqfAmnwluf1OwMjz39HjfLPci0Q==- dependencies:- aproba "^1.0.3 || ^2.0.0"- color-support "^1.1.2"- console-control-strings "^1.0.0"- has-unicode "^2.0.1"- object-assign "^4.1.1"- signal-exit "^3.0.0"- string-width "^4.2.3"- strip-ansi "^6.0.1"- wide-align "^1.1.2"-gauge@^4.0.3:version "4.0.4"resolved "https://registry.npmjs.org/gauge/-/gauge-4.0.4.tgz"@@ -3883,13 +3832,6 @@ mailing@^0.8.3-next.0:uglify-js "^3.15.4"yargs "^17.5.1"-make-dir@^3.1.0:- version "3.1.0"- resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f"- integrity sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==- dependencies:- semver "^6.0.0"-make-fetch-happen@^10.0.3, make-fetch-happen@^10.0.6, make-fetch-happen@^10.2.0:version "10.2.1"resolved "https://registry.npmjs.org/make-fetch-happen/-/make-fetch-happen-10.2.1.tgz"@@ -4492,11 +4434,6 @@ no-case@^3.0.4:lower-case "^2.0.2"tslib "^2.0.3"-node-addon-api@^5.0.0:- version "5.0.0"- resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-5.0.0.tgz#7d7e6f9ef89043befdb20c1989c905ebde18c501"- integrity sha512-CvkDw2OEnme7ybCykJpVcKH+uAOLV2qLqiyla128dN9TkEWfrYmxG6C2boDe5KcNQqZF3orkqzGgOMvZ/JNekA==-node-fetch@^2.6.0, node-fetch@^2.6.1, node-fetch@^2.6.7:version "2.6.7"resolved "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz"@@ -4740,16 +4677,6 @@ npm@^8.19.0:which "^2.0.2"write-file-atomic "^4.0.1"-npmlog@^5.0.1:- version "5.0.1"- resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-5.0.1.tgz#f06678e80e29419ad67ab964e0fa69959c1eb8b0"- integrity sha512-AqZtDUWOMKs1G/8lwylVjrdYgqA4d9nu8hc+0gzRxlDb1I10+FHBGMXs6aiQHFdCUUlqH99MUMuLfzWDNDtfxw==- dependencies:- are-we-there-yet "^2.0.0"- console-control-strings "^1.1.0"- gauge "^3.0.0"- set-blocking "^2.0.0"-npmlog@^6.0.0, npmlog@^6.0.2:version "6.0.2"resolved "https://registry.npmjs.org/npmlog/-/npmlog-6.0.2.tgz"@@ -5545,7 +5472,7 @@ semver@^5.6.0:resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==-semver@^6.0.0, semver@^6.3.0:+semver@^6.3.0:version "6.3.0"resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==@@ -5586,7 +5513,7 @@ sigmund@^1.0.1:resolved "https://registry.yarnpkg.com/sigmund/-/sigmund-1.0.1.tgz#3ff21f198cad2175f9f3b781853fd94d0d19b590"integrity sha512-fCvEXfh6NWpm+YSuY2bpXb/VIihqWA6hLsgboC+0nl71Q7N7o2eaCW8mJa/NLvQhs6jpd3VZV4UiUQlV6+lc8g==-signal-exit@^3.0.0, signal-exit@^3.0.7:+signal-exit@^3.0.7:version "3.0.7"resolved "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz"integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==@@ -6161,7 +6088,7 @@ which@^2.0.2:dependencies:isexe "^2.0.0"-wide-align@^1.1.2, wide-align@^1.1.5:+wide-align@^1.1.5:version "1.1.5"resolved "https://registry.npmjs.org/wide-align/-/wide-align-1.1.5.tgz"integrity sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==