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

Function parseJsonPointer

ui/src/protocol/path-resolver.ts:94–113  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

92 * @throws {PathError} 如果路径无效
93 */
94export function parseJsonPointer(path: string): string[] {
95 if (!isValidJsonPointer(path)) {
96 throw new PathError(
97 `Invalid JSON Pointer: "${path}". Path must be empty or start with "/"`,
98 PathErrorCodes.INVALID_PATH,
99 { path },
100 );
101 }
102
103 // 空字符串表示根路径
104 if (path === '') {
105 return [];
106 }
107
108 // 移除开头的 "/" 并分割
109 const tokens = path.slice(1).split('/');
110
111 // 解码每个路径段
112 return tokens.map(decodeJsonPointerToken);
113}
114
115/**
116 * 将路径段数组转换为 JSON Pointer 路径

Callers 9

resolvePathFunction · 0.85
getDataFunction · 0.85
setDataFunction · 0.85
hasPathFunction · 0.85
deleteDataFunction · 0.85
getParentPathFunction · 0.85
getLastTokenFunction · 0.85
joinPathsFunction · 0.85

Calls 1

isValidJsonPointerFunction · 0.85

Tested by

no test coverage detected