(path: string)
| 521 | * @returns 父路径,如果是根路径则返回 null |
| 522 | */ |
| 523 | export function getParentPath(path: string): string | null { |
| 524 | if (!isValidJsonPointer(path) || path === '') { |
| 525 | return null; |
| 526 | } |
| 527 | |
| 528 | const tokens = parseJsonPointer(path); |
| 529 | if (tokens.length === 0) { |
| 530 | return null; |
| 531 | } |
| 532 | |
| 533 | return toJsonPointer(tokens.slice(0, -1)); |
| 534 | } |
| 535 | |
| 536 | /** |
| 537 | * 获取路径的最后一个段 |
no test coverage detected