|
|
@@ -56,7 +56,6 @@ public:
|
|
|
|
|
|
detail::Reference canonicalize(detail::Reference const & ref,
|
|
|
detail::Reference const & parent) const {
|
|
|
-
|
|
|
// Relative URI, not in the HEREDOC (or we set an $id)
|
|
|
if (ref.uri().empty() and ref.anchor().empty()) {
|
|
|
return detail::Reference(canonicalize(parent).root(), ref.pointer());
|
|
|
@@ -64,7 +63,15 @@ public:
|
|
|
|
|
|
// TODO(samjaffe): Clean this clause up
|
|
|
URI uri = ref.uri().empty() ? parent.root().uri() : ref.uri();
|
|
|
- if (uri.is_rootless() && not uri.empty()) {
|
|
|
+ if (uri.empty()) {
|
|
|
+ auto parent_uri = canonicalize(parent).uri();
|
|
|
+ if (parent_uri == parent.uri() && parent.uri().empty()) {
|
|
|
+ auto it = absolute_to_canonical_.find(detail::Reference());
|
|
|
+ if (it != absolute_to_canonical_.end()) {
|
|
|
+ uri = it->second.uri();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (uri.is_rootless()) {
|
|
|
auto parent_uri = canonicalize(parent).uri();
|
|
|
if (parent_uri == parent.uri() && parent.uri().empty()) {
|
|
|
auto it = absolute_to_canonical_.find(detail::Reference());
|
|
|
@@ -131,9 +138,10 @@ private:
|
|
|
root = detail::RootReference(schema[id].as_string());
|
|
|
if (root.uri().empty()) {
|
|
|
root = detail::RootReference(where.uri(), root.anchor());
|
|
|
- } else if (root.uri().is_rootless() && not where.uri().empty()) {
|
|
|
- // TODO(samjaffe): Should there also be something for is_relative?
|
|
|
+ } else if (root.uri().is_relative() && not where.uri().empty()) {
|
|
|
root = detail::RootReference(where.uri().parent() / root.uri(), root.anchor());
|
|
|
+ } else if (root.uri().is_rootless() && not where.uri().empty()) {
|
|
|
+ root = detail::RootReference(where.uri().root() / root.uri(), root.anchor());
|
|
|
}
|
|
|
|
|
|
cache(root, where, json);
|