getBaseURL()function

getBaseURL(input: Nullish<PossibleURL>): BaseURL | undefined
ParamType
inputNullish<PossibleURL>
URL string, URL object, or path to normalise. required
Return
BaseURL | undefined
BaseURL with a trailing-slash pathname, or undefined if input is not a true URL.

Get a Base URL — a true URL whose pathname is normalised to end in a trailing slash.

  • Falsy or non-URL input returns undefined.
  • A URL without a trailing slash is cloned and given one (the input is never mutated).

Examples

getBaseURL("http://x.com/a"); // `http://x.com/a/`