From bd40dcfc2bc7c9014ea1f33482fb63aacbcdfe87 Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Tue, 8 Jan 2019 14:52:57 +0100 Subject: vendor: update everything * If possible, update each dependency to the latest available version. * Use releases over commit IDs and avoid vendoring branches. Signed-off-by: Valentin Rothberg --- vendor/github.com/xeipuuv/gojsonreference/reference.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'vendor/github.com/xeipuuv/gojsonreference/reference.go') diff --git a/vendor/github.com/xeipuuv/gojsonreference/reference.go b/vendor/github.com/xeipuuv/gojsonreference/reference.go index d4d2eca0a..645729130 100644 --- a/vendor/github.com/xeipuuv/gojsonreference/reference.go +++ b/vendor/github.com/xeipuuv/gojsonreference/reference.go @@ -27,11 +27,12 @@ package gojsonreference import ( "errors" - "github.com/xeipuuv/gojsonpointer" "net/url" "path/filepath" "runtime" "strings" + + "github.com/xeipuuv/gojsonpointer" ) const ( @@ -124,16 +125,21 @@ func (r *JsonReference) parse(jsonReferenceString string) (err error) { // Creates a new reference from a parent and a child // If the child cannot inherit from the parent, an error is returned func (r *JsonReference) Inherits(child JsonReference) (*JsonReference, error) { - childUrl := child.GetUrl() - parentUrl := r.GetUrl() - if childUrl == nil { + if child.GetUrl() == nil { return nil, errors.New("childUrl is nil!") } - if parentUrl == nil { + + if r.GetUrl() == nil { return nil, errors.New("parentUrl is nil!") } - ref, err := NewJsonReference(parentUrl.ResolveReference(childUrl).String()) + // Get a copy of the parent url to make sure we do not modify the original. + // URL reference resolving fails if the fragment of the child is empty, but the parent's is not. + // The fragment of the child must be used, so the fragment of the parent is manually removed. + parentUrl := *r.GetUrl() + parentUrl.Fragment = "" + + ref, err := NewJsonReference(parentUrl.ResolveReference(child.GetUrl()).String()) if err != nil { return nil, err } -- cgit v1.2.3-54-g00ecf