@@ -156,7 +156,10 @@ def lookup(self, ref: str) -> tuple[Schema, Resolver]:
156
156
uri , fragment = self ._base_uri , ref [1 :]
157
157
else :
158
158
uri , fragment = urldefrag (urljoin (self ._base_uri , ref ))
159
+
159
160
target , registry = self ._registry .resource_at (uri )
161
+ base_uri = uri
162
+
160
163
if fragment .startswith ("/" ):
161
164
segments = unquote (fragment [1 :]).split ("/" )
162
165
for segment in segments :
@@ -165,15 +168,23 @@ def lookup(self, ref: str) -> tuple[Schema, Resolver]:
165
168
else :
166
169
segment = segment .replace ("~1" , "/" ).replace ("~0" , "~" )
167
170
target = target [segment ] # type: ignore # this can't be a bool
171
+ # FIXME: this is wrong, we need to know that we are crossing
172
+ # the boundary of a *schema* specifically
173
+ if not isinstance (target , Sequence ):
174
+ id = self ._registry ._specification .id_of (target )
175
+ if id is not None :
176
+ base_uri = urljoin (base_uri , id ).rstrip ("#" )
168
177
elif fragment :
169
178
anchor = registry .anchors_at (uri = uri )[fragment ]
170
179
target , uri = anchor .resolve (resolver = self , uri = uri )
171
180
172
- id = self ._registry ._specification .id_of (target )
173
- if id is not None :
174
- base_uri = urljoin (self ._base_uri , id ).rstrip ("#" )
181
+ id = self ._registry ._specification .id_of (target )
182
+ if id is not None :
183
+ base_uri = urljoin (self ._base_uri , id ).rstrip ("#" )
175
184
else :
176
- base_uri = uri
185
+ id = self ._registry ._specification .id_of (target )
186
+ if id is not None :
187
+ base_uri = urljoin (self ._base_uri , id ).rstrip ("#" )
177
188
return target , self .evolve (base_uri = base_uri , registry = registry )
178
189
179
190
def with_root (self , root ) -> Resolver :
0 commit comments