Skip to content

Function: joinBasePath()

API / @xmachines/play-router / index / joinBasePath

function joinBasePath(basePath, path): string;

Defined in: packages/play-url/src/base-path.ts:308

Adds the base path to an outbound path of the machine.

The function joins the PATHNAME only. A query string and a hash fragment of the path of the machine stay at the end, because the prefix belongs in front of the path.

Parameters

ParameterTypeDescription
basePathstringThe concrete prefix of resolveBasePath. "" adds nothing.
pathstringThe path of the machine, for example "/dashboard" or "/dates?trip=one-way".

Returns

string

The location for the router of the host.

Example

joinBasePath("/abc123/play", "/dashboard"); // "/abc123/play/dashboard"
joinBasePath("/abc123/play", "/"); // "/abc123/play"
joinBasePath("/abc123/play", "/x?tab=a"); // "/abc123/play/x?tab=a"
joinBasePath("/abc123/play", "#/home"); // "/abc123/play#/home"
joinBasePath("", "/dashboard"); // "/dashboard"