MCPcopy Create free account
hub / github.com/astercloud/aster / joinPaths

Function joinPaths

ui/src/protocol/path-resolver.ts:563–581  ·  view source on GitHub ↗
(basePath: string, relativePath: string)

Source from the content-addressed store, hash-verified

561 * @returns 合并后的路径
562 */
563export function joinPaths(basePath: string, relativePath: string): string {
564 if (!isValidJsonPointer(basePath)) {
565 throw new PathError(
566 `Invalid base path: "${basePath}"`,
567 PathErrorCodes.INVALID_PATH,
568 { basePath },
569 );
570 }
571
572 // 如果相对路径是绝对路径,直接返回
573 if (relativePath.startsWith('/')) {
574 return relativePath;
575 }
576
577 const baseTokens = parseJsonPointer(basePath);
578 const relativeTokens = relativePath.split('/').map(decodeJsonPointerToken);
579
580 return toJsonPointer([...baseTokens, ...relativeTokens]);
581}

Callers 1

Calls 3

isValidJsonPointerFunction · 0.85
parseJsonPointerFunction · 0.85
toJsonPointerFunction · 0.85

Tested by

no test coverage detected