UNPKG

fumadocs-core

Version:

The library for building a documentation website in Next.js

34 lines (32 loc) 618 B
// src/utils/path.ts function splitPath(path) { return path.split("/").filter((p) => p.length > 0); } function joinPath(...paths) { const out = []; const parsed = paths.flatMap(splitPath); for (const seg of parsed) { switch (seg) { case "..": out.pop(); break; case ".": break; default: out.push(seg); } } return out.join("/"); } function slash(path) { const isExtendedLengthPath = path.startsWith("\\\\?\\"); if (isExtendedLengthPath) { return path; } return path.replaceAll("\\", "/"); } export { splitPath, joinPath, slash };