mirror of
https://github.com/lukevella/rallly.git
synced 2025-06-02 02:31:53 +02:00
🔗 Add support for shorter urls (#750)
This commit is contained in:
parent
30a1136529
commit
2e5468ed65
5 changed files with 16 additions and 5 deletions
|
@ -6,10 +6,17 @@ const getVercelUrl = () => {
|
|||
: null;
|
||||
};
|
||||
|
||||
export function absoluteUrl(path = "") {
|
||||
export function absoluteUrl(subpath = "") {
|
||||
const baseUrl =
|
||||
process.env.NEXT_PUBLIC_BASE_URL ??
|
||||
getVercelUrl() ??
|
||||
`http://localhost:${port}`;
|
||||
return `${baseUrl}${path}`;
|
||||
const url = new URL(subpath, baseUrl);
|
||||
return url.href;
|
||||
}
|
||||
|
||||
export function shortUrl(subpath = "") {
|
||||
const baseUrl = process.env.NEXT_PUBLIC_SHORT_BASE_URL ?? absoluteUrl();
|
||||
const url = new URL(subpath, baseUrl);
|
||||
return url.href;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue