Home > @asl-19/js-utils > getAbsoluteUrl
Given provided protocol + host string and root-relative URL string returns an absolute (fully-qualified) URL.
Signature:
getAbsoluteUrl: ({ protocolAndHost, rootRelativeUrl, }: {
protocolAndHost: string;
rootRelativeUrl: string;
}) => string|
Parameter |
Type |
Description |
|---|---|---|
|
{ protocolAndHost, rootRelativeUrl, } |
{ protocolAndHost: string; rootRelativeUrl: string; } |
Returns:
string
protocolAndHostshould look like"https://asl19.org", with no trailing slash. In ASL19 Next.js projects this is probablyprocess.env.NEXT_PUBLIC_WEB_URL. -rootRelativeUrlshould start with"/".
getAbsoluteUrl({
protocolAndHost: "https://hello.com",
rootRelativeUrl: "/foo",
})
// "https://hello.com/foo"