|
|
@@ -17,12 +17,29 @@ public:
|
|
|
Pointer() = default;
|
|
|
Pointer(std::vector<std::variant<std::string, size_t>> const & tokens) : tokens_(tokens) {}
|
|
|
Pointer(std::string_view path) {
|
|
|
+ if (path.empty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
auto append_with_parse = [this](std::string in) {
|
|
|
- if (in.find_first_not_of("0123456789") == std::string::npos) {
|
|
|
- tokens_.push_back(std::stoull(in));
|
|
|
- } else {
|
|
|
- tokens_.push_back(std::move(in));
|
|
|
+ if (not in.empty() && in.find_first_not_of("0123456789") == std::string::npos) {
|
|
|
+ return tokens_.push_back(std::stoull(in));
|
|
|
}
|
|
|
+
|
|
|
+ for (size_t i = 0; i < in.size(); ++i) {
|
|
|
+ if (in[i] == '%') {
|
|
|
+ char const enc[3] = {in[i + 1], in[i + 2]};
|
|
|
+ in.replace(i, 3, 1, char(std::stoi(enc, nullptr, 16)));
|
|
|
+ } else if (in[i] != '~') {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (in[i + 1] == '0') {
|
|
|
+ in.replace(i, 2, 1, '~');
|
|
|
+ } else if (in[i + 1] == '1') {
|
|
|
+ in.replace(i, 2, 1, '/');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tokens_.push_back(std::move(in));
|
|
|
};
|
|
|
|
|
|
path.remove_prefix(1);
|
|
|
@@ -31,9 +48,7 @@ public:
|
|
|
append_with_parse(std::string(path.substr(0, p)));
|
|
|
}
|
|
|
|
|
|
- if (not path.empty()) {
|
|
|
- append_with_parse(std::string(path));
|
|
|
- }
|
|
|
+ append_with_parse(std::string(path));
|
|
|
}
|
|
|
|
|
|
template <Adapter A> A walk(A document) const {
|