MCPcopy Create free account
hub / github.com/ProtonDriveApps/sdk / splitPathSegments

Function splitPathSegments

cli/src/cli/paths.ts:411–435  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

409 private async getNodeByName(parentNode: NodeEntity, name: string) {
410 for await (const maybeChild of this.publicLinkSdk.iterateFolderChildren(parentNode)) {
411 if (getName(maybeChild) === name) {
412 return maybeChild;
413 }
414 }
415 throw new ValidationError(`Node not found: ${name}`);
416 }
417}
418
419export function pathDirname(fullPath: string): string {
420 const segments = splitPathSegments(fullPath);
421 return joinPathSegments(segments.slice(0, -1));
422}
423
424export function pathBasename(fullPath: string): string {
425 const segments = splitPathSegments(fullPath);
426 return segments[segments.length - 1] ?? '';
427}
428
429/**
430 * Split a remote path into segments. Unescaped `/` separates segments; `\/` is literal `/`.
431 */
432export function splitPathSegments(path: string): string[] {
433 const segments: string[] = [];
434 let current = '';
435
436 for (let i = 0; i < path.length; i++) {
437 const char = path[i];
438 if (char === '\\' && i + 1 < path.length) {

Callers 9

paths.test.tsFile · 0.90
getNodeInternalMethod · 0.85
sectionPathMethod · 0.85
sectionRootNodeNameMethod · 0.85
getNodeByPathMethod · 0.85
getNodeByPathMethod · 0.85
pathDirnameFunction · 0.85
pathBasenameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected