♻️ Update eslint config (#1424)

This commit is contained in:
Luke Vella 2024-11-02 11:50:09 +00:00 committed by GitHub
parent 01396b6129
commit d55131c2ab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
162 changed files with 337 additions and 266 deletions

View file

@ -0,0 +1,38 @@
const port = process.env.PORT || 3000;
const getVercelUrl = () => {
return process.env.NEXT_PUBLIC_VERCEL_URL
? `https://${process.env.NEXT_PUBLIC_VERCEL_URL}`
: null;
};
function joinPath(baseUrl: string, subpath = "") {
if (subpath) {
const url = new URL(subpath, baseUrl);
return url.href;
}
return baseUrl;
}
export function absoluteUrl(subpath = "", query: Record<string, string> = {}) {
const baseUrl =
process.env.NEXT_PUBLIC_BASE_URL ??
getVercelUrl() ??
`http://localhost:${port}`;
const url = new URL(subpath, baseUrl);
Object.entries(query).forEach(([key, value]) => {
url.searchParams.set(key, value);
});
const urlString = url.href;
return urlString.endsWith("/") ? urlString.slice(0, -1) : urlString;
}
export function shortUrl(subpath = "") {
const baseUrl = process.env.NEXT_PUBLIC_SHORT_BASE_URL ?? absoluteUrl();
return joinPath(baseUrl, subpath);
}