Given 2 paths, it returns whether the second path is inside or equal to the first path.
By default, paths are compared with pathe, which treats `` as a separator
on every platform. This behaviour is kept for backward compatibility.
When native is true, paths are compared with the current OS's native path
semantics, so literal backslashes on POSIX are preserved as filename
characters. Use native: true for security or containment checks on
resolved filesystem paths.
Symbolic links are not resolved; use fileRealPath from the fs module first
when checking physical containment.
Parameters
mainPath: string
The main path.
subpath: string
The subpath.
options: IsSubpathOptions = ...
Comparison options. Set native to true to use the OS's native path semantics. Defaults to false.
Returns boolean
Whether the subpath is inside or equal to the main path.
Given 2 paths, it returns whether the second path is inside or equal to the first path.
By default, paths are compared with pathe, which treats `` as a separator on every platform. This behaviour is kept for backward compatibility.
When
nativeis true, paths are compared with the current OS's native path semantics, so literal backslashes on POSIX are preserved as filename characters. Usenative: truefor security or containment checks on resolved filesystem paths.Symbolic links are not resolved; use fileRealPath from the fs module first when checking physical containment.