getBaseName
The getBaseName() function returns the last segment of a path (after the final slash), with optional extension removal.
WARNING
Works only with POSIX paths (not Windows paths).
Interactive example
Syntax
typescript
function getBaseName<
GenericPath extends string
>(
path: GenericPath,
params?: {
removeExtension?: boolean;
}
): string | null;Parameters
path: The path to analyze.params.removeExtension: Whentrue, removes the extension from the final segment.
Return value
The last path segment (after the final /), with the extension removed if requested, or null when no segment is found (including when the path has no /).
See also
getExtensionName- Returns the extension of a pathgetParentFolderPath- Returns the parent folder
