|
@@ -33,29 +33,26 @@ public:
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
RelativePointer rval;
|
|
RelativePointer rval;
|
|
|
- if (auto pos = path.find('/'); pos != path.npos) {
|
|
|
|
|
|
|
+ if (size_t pos = path.find('/'); pos != path.npos) {
|
|
|
// Handle the JSON-Pointer version
|
|
// Handle the JSON-Pointer version
|
|
|
expected ptr = Pointer::parse(path.substr(pos));
|
|
expected ptr = Pointer::parse(path.substr(pos));
|
|
|
JVALIDATE_PROPIGATE_UNEXPECTED(ptr);
|
|
JVALIDATE_PROPIGATE_UNEXPECTED(ptr);
|
|
|
rval.pointer_ = *std::move(ptr);
|
|
rval.pointer_ = *std::move(ptr);
|
|
|
path.remove_suffix(path.size() - pos);
|
|
path.remove_suffix(path.size() - pos);
|
|
|
- } else if (path.back() == '#') {
|
|
|
|
|
|
|
+ } else if (path.ends_with('#')) {
|
|
|
rval.requests_key_ = true;
|
|
rval.requests_key_ = true;
|
|
|
path.remove_suffix(1);
|
|
path.remove_suffix(1);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (path.find_first_not_of("0123456789") != std::string_view::npos) {
|
|
|
|
|
- return unexpected("RelativePointer must end in a pointer, or a '#'");
|
|
|
|
|
|
|
+ if (path.starts_with('0') && path != "0") {
|
|
|
|
|
+ return unexpected("Cannot zero-prefix a relative pointer");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
size_t read = 0;
|
|
size_t read = 0;
|
|
|
expected parent_steps = parse_integer<size_t>(path, {.read = read});
|
|
expected parent_steps = parse_integer<size_t>(path, {.read = read});
|
|
|
-
|
|
|
|
|
- JVALIDATE_PROPIGATE_UNEXPECTED(parent_steps.transform_error(to_message));
|
|
|
|
|
- EXPECT_M(read == path.size(), "Extra chars in RelativePointer");
|
|
|
|
|
-
|
|
|
|
|
- // Will throw an exception if path contains any non-numeric characters, or
|
|
|
|
|
|
|
+ // Will return unexpected if path contains any non-numeric characters, or
|
|
|
// if path represents a number that is out of the bounds of a size_t.
|
|
// if path represents a number that is out of the bounds of a size_t.
|
|
|
|
|
+ JVALIDATE_PROPIGATE_UNEXPECTED(parent_steps.transform_error(to_message));
|
|
|
rval.parent_steps_ = *parent_steps;
|
|
rval.parent_steps_ = *parent_steps;
|
|
|
return rval;
|
|
return rval;
|
|
|
}
|
|
}
|