Parse a JSON pointer path into parts
(path: &str)
| 606 | |
| 607 | /// Parse a JSON pointer path into parts |
| 608 | fn parse_path(path: &str) -> Result<Vec<String>, PatchError> { |
| 609 | if !path.starts_with('/') { |
| 610 | return Err(PatchError::InvalidPatch(format!( |
| 611 | "Path must start with '/': {}", |
| 612 | path |
| 613 | ))); |
| 614 | } |
| 615 | |
| 616 | Ok(path[1..] |
| 617 | .split('/') |
| 618 | .map(|part| { |
| 619 | // Unescape ~1 -> / and ~0 -> ~ |
| 620 | part.replace("~1", "/").replace("~0", "~") |
| 621 | }) |
| 622 | .collect()) |
| 623 | } |
| 624 | |
| 625 | /// Split a path into parent path and final key |
| 626 | fn split_path(path: &str) -> Result<(&str, &str), PatchError> { |
no outgoing calls
no test coverage detected