Skip to content

Function: isAbsoluteRoute()

API / @xmachines/play-xstate / isAbsoluteRoute

function isAbsoluteRoute(path): boolean;

Defined in: packages/play-xstate/src/routing/derive-route.ts:163

Tells you if the route path is absolute

The function decides if a route path is absolute, which means that it starts with /, or relative. An absolute path inherits nothing from a parent route. A relative path joins a parent path, for a nested routing.

Parameters

ParameterTypeDescription
pathstringThe route path to test

Returns

boolean

true when the path starts with ’/’. In every other case, false

Example

import { isAbsoluteRoute } from "@xmachines/play-xstate";
console.log(isAbsoluteRoute("/dashboard")); // true
console.log(isAbsoluteRoute("settings")); // false
console.log(isAbsoluteRoute("./about")); // false

See

deriveRoute for the read of a route