Skip to content

Commit

Permalink
Fix merging of refs if both are plain name fragments
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarmueller committed Aug 15, 2018
1 parent 183565c commit 927a180
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ object Refs {
).getOrElse(l)

case r@RelativeRef(relativeRef) =>
if (relativeRef.startsWith("#") && currentScope.exists(_.value.startsWith("#"))) {
// both refs are plain name fragments, switch scope
ref
} else
if (relativeRef.startsWith("#")) {
// ref is plain name fragment
currentScope.map(url =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ class RefsSpec extends Specification {
"Refs" should {
"should define resolution scopes" in {

Refs.mergeRefs(
Ref("#foo"),
Some(Ref("#bar"))
) must beEqualTo(Ref("#foo"))

Refs.mergeRefs(
Ref("#"), Some(Ref("http://x.y.z/rootschema.json#"))
) must beEqualTo(Ref("http://x.y.z/rootschema.json#"))
Expand Down

0 comments on commit 927a180

Please sign in to comment.