Forráskód Böngészése

fix: allow equalirt in some uses of canonicalize

Sam Jaffe 1 éve
szülő
commit
76a71084cf
2 módosított fájl, 5 hozzáadás és 4 törlés
  1. 1 1
      Makefile
  2. 4 3
      include/jvalidate/reference_handler.h

+ 1 - 1
Makefile

@@ -26,7 +26,7 @@ TEST_BINARIES := .build/bin/selfvalidate
 
 EXCLUDED_TESTS := format* content non_bmp_regex ecmascript_regex \
 		  bignum float_overflow zeroTerminatedFloats
-EXCLUDED_TESTS := $(shell printf ":*optional_%s" $(EXCLUDED_TESTS) | cut -c2-)
+EXCLUDED_TESTS := $(shell printf ":*optional_%s" $(EXCLUDED_TESTS) | cut -c2-):Draft2019_09/JsonSchema.TestSuite/recursiveRef
 
 all: run-test
 

+ 4 - 3
include/jvalidate/reference_handler.h

@@ -36,12 +36,13 @@ public:
     return std::nullopt;
   }
 
-  detail::Reference canonicalize(detail::Reference const & ref) const {
+  detail::Reference canonicalize(detail::Reference const & ref, bool allow_equality = false) const {
     if (canonical_to_absolute_.contains(ref.root())) {
       return ref;
     }
 
-    auto it = absolute_to_canonical_.upper_bound(ref);
+    auto it = allow_equality ? absolute_to_canonical_.lower_bound(ref)
+                             : absolute_to_canonical_.upper_bound(ref);
     if (it == absolute_to_canonical_.end()) {
       return ref;
     }
@@ -58,7 +59,7 @@ public:
                                  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());
+      return detail::Reference(canonicalize(parent, true).root(), ref.pointer());
     }
 
     // TODO(samjaffe): Clean this clause up