summaryrefslogtreecommitdiff
path: root/vendor/github.com/xeipuuv/gojsonreference/reference.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-01-11 05:39:12 -0800
committerGitHub <noreply@github.com>2019-01-11 05:39:12 -0800
commitb3eb23d671425775673f86bd02b9c89ef781f590 (patch)
tree5f06e4e289f16d9164d692590a3fe6541b5384cf /vendor/github.com/xeipuuv/gojsonreference/reference.go
parent26f2b7debde313af4a5ae39727c66a3f8fd59be4 (diff)
parentbd40dcfc2bc7c9014ea1f33482fb63aacbcdfe87 (diff)
downloadpodman-b3eb23d671425775673f86bd02b9c89ef781f590.tar.gz
podman-b3eb23d671425775673f86bd02b9c89ef781f590.tar.bz2
podman-b3eb23d671425775673f86bd02b9c89ef781f590.zip
Merge pull request #2102 from vrothberg/vendor-update
vendor: update everything
Diffstat (limited to 'vendor/github.com/xeipuuv/gojsonreference/reference.go')
-rw-r--r--vendor/github.com/xeipuuv/gojsonreference/reference.go18
1 files changed, 12 insertions, 6 deletions
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
}