Skip to content

Commit

Permalink
oops
Browse files Browse the repository at this point in the history
  • Loading branch information
steven-tey committed Feb 22, 2024
1 parent fb5c5d5 commit a4f82bc
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions apps/web/scripts/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,27 @@ export const redis = new Redis({
token: process.env.UPSTASH_REDIS_REST_TOKEN || "",
});

export function linkConstructor({
key,
domain = "dub.sh",
localhost,
pretty,
noDomain,
}: {
key: string;
domain?: string;
localhost?: boolean;
pretty?: boolean;
noDomain?: boolean;
}) {
const link = `${
localhost ? "http://home.localhost:8888" : `https://${domain}`
}${key !== "_root" ? `/${key}` : ""}`;

if (noDomain) return `/${key}`;
return pretty ? link.replace(/^https?:\/\//, "") : link;
}

export const chunk = <T>(array: T[], chunk_size: number): T[][] => {
return array.reduce((resultArray, item, index) => {
const chunkIndex = Math.floor(index / chunk_size);
Expand Down

0 comments on commit a4f82bc

Please sign in to comment.