2022-10-20 20:15:44 +00:00
|
|
|
/**
|
|
|
|
* Extracts all segments from the path query param as a string array.
|
|
|
|
*
|
2023-08-29 22:40:45 +00:00
|
|
|
* @param path The query path param
|
2022-10-20 20:15:44 +00:00
|
|
|
* @return The list of segments from the path
|
|
|
|
*/
|
|
|
|
export function getSegmentsFromPath( path?: string ): string[] {
|
|
|
|
const firstIndex = path?.startsWith( '/' ) ? 1 : 0;
|
|
|
|
const lastIndex = path?.endsWith( '/' ) ? -1 : undefined;
|
|
|
|
return path?.slice( firstIndex, lastIndex )?.split( '/' ) ?? [];
|
|
|
|
}
|