UNPKG

@lifaon/path

Version:

Useful tool to manage paths like the URL object

14 lines (13 loc) 951 B
import type { IPathSegment } from '../../../../../types/segments/segment/path-segment.type.js'; import type { ISpecialSegmentsAllowedForBasename } from '../../../../../types/segments/special-segments-allowed-for-basename.type.js'; export declare const DEFAULT_SPECIAL_SEGMENTS_ALLOWED_FOR_BASENAME: Set<ISpecialSegmentsAllowedForBasename>; export interface IGetBasenameOfPathSegmentOptions { readonly rootRegExp: RegExp; readonly allowedSpecialSegments?: Set<ISpecialSegmentsAllowedForBasename>; } /** * Returns the basename of a segment, without 'ext' if provided * - returns null if segment is special (relative or root) and options.allowedSpecialSegments doesn't include it * INFO: 'basename' must be a valid entry, including relative and root */ export declare function getBasenameOfPathSegment(segment: IPathSegment, ext: string | undefined, { rootRegExp, allowedSpecialSegments, }: IGetBasenameOfPathSegmentOptions): string | null;