Skip to content

Latest commit

 

History

History
70 lines (38 loc) · 1.22 KB

File metadata and controls

70 lines (38 loc) · 1.22 KB

Home > @asl-19/js-utils > getAbsoluteUrl

getAbsoluteUrl() function

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

Parameters

Parameter

Type

Description

{ protocolAndHost, rootRelativeUrl, }

{ protocolAndHost: string; rootRelativeUrl: string; }

Returns:

string

Remarks

  • protocolAndHost should look like "https://asl19.org", with no trailing slash. In ASL19 Next.js projects this is probably process.env.NEXT_PUBLIC_WEB_URL. - rootRelativeUrl should start with "/".

Example

getAbsoluteUrl({
 protocolAndHost: "https://hello.com",
 rootRelativeUrl: "/foo",
})
// "https://hello.com/foo"