diff --git a/reference.go b/reference.go
index <HASH>..<HASH> 100644
--- a/reference.go
+++ b/reference.go
@@ -125,7 +125,7 @@ func (s *Schema) refToSchema(str string, rootSchema Schema, loadExternal bool) (
 	if err == nil && parentURL.IsAbs() {
 		sURL, err := url.Parse(str)
 		if err == nil && !sURL.IsAbs() && !strings.HasPrefix(str, "#") {
-			str = strings.TrimSuffix(s.parentId, "/") + "/" + strings.TrimPrefix(str, "/")
+			str = parentURL.ResolveReference(sURL).String()
 		}
 	}
Fix resolving ref against resolution scope