UNPKG

@lifaon/path

Version:

Useful tool to manage paths like the URL object

21 lines 677 B
import { SLASH_REGEXP } from '../../../platform-config/constants/slash-regexp.constant.js'; /** * Converts a string path to an `IUncheckedPathSegments`. */ export function convertStringPathToUncheckedPathSegments(path, { rootRegExp }) { if (path === '') { return []; } else { rootRegExp.lastIndex = 0; const match = rootRegExp.exec(path); if (match === null) { return path.split(SLASH_REGEXP); } else { path = path.slice(match[0].length); return [match[1], ...path.split(SLASH_REGEXP)]; } } } //# sourceMappingURL=convert-string-path-to-unchecked-path-segments.js.map