Skip to main content

Function: isWithin()

isWithin(candidate, root): boolean

Defined in: packages/authz/src/tree-path.ts:49

Whether candidate is root or lies beneath it. Compared by whole segment: /oktoid/smoke-2 is NOT within /oktoid/smoke, which a naive prefix test gets wrong. Nothing is within a tenant root from /'s side: / is within only /.

Parameters​

candidate​

TreePath

The path being tested.

root​

TreePath

The path it must lie within.

Returns​

boolean

true when candidate equals root or is a descendant of it.