(path: string)
| 540 | * @returns 最后一个路径段,如果是根路径则返回 null |
| 541 | */ |
| 542 | export function getLastToken(path: string): string | null { |
| 543 | if (!isValidJsonPointer(path) || path === '') { |
| 544 | return null; |
| 545 | } |
| 546 | |
| 547 | const tokens = parseJsonPointer(path); |
| 548 | if (tokens.length === 0) { |
| 549 | return null; |
| 550 | } |
| 551 | |
| 552 | const lastToken = tokens[tokens.length - 1]; |
| 553 | return lastToken !== undefined ? lastToken : null; |
| 554 | } |
| 555 | |
| 556 | /** |
| 557 | * 合并两个路径 |
no test coverage detected