File tree Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 22Changelog
33=========
44
5+ v0.27.3
6+ -------
7+
8+ * Also strip fragments when using ``__getitem__ `` on URIs with empty fragments.
9+
510v0.27.2
611-------
712
Original file line number Diff line number Diff line change @@ -241,7 +241,7 @@ def __getitem__(self, uri: URI) -> Resource[D]:
241241 Return the (already crawled) `Resource` identified by the given URI.
242242 """
243243 try :
244- return self ._resources [uri ]
244+ return self ._resources [uri . rstrip ( "#" ) ]
245245 except KeyError :
246246 raise exceptions .NoSuchResource (ref = uri )
247247
Original file line number Diff line number Diff line change @@ -155,11 +155,21 @@ def test_contents(self):
155155 registry = Registry ().with_resource (uri , resource )
156156 assert registry .contents (uri ) == {"foo" : "bar" }
157157
158+ def test_getitem_strips_empty_fragments (self ):
159+ uri = "http://example.com/"
160+ resource = ID_AND_CHILDREN .create_resource ({"ID" : uri + "#" })
161+ registry = resource @ Registry ()
162+ assert registry [uri ] == registry [uri + "#" ] == resource
163+
158164 def test_contents_strips_empty_fragments (self ):
159165 uri = "http://example.com/"
160166 resource = ID_AND_CHILDREN .create_resource ({"ID" : uri + "#" })
161167 registry = resource @ Registry ()
162- assert registry .contents (uri ) == {"ID" : uri + "#" }
168+ assert (
169+ registry .contents (uri )
170+ == registry .contents (uri + "#" )
171+ == {"ID" : uri + "#" }
172+ )
163173
164174 def test_crawled_anchor (self ):
165175 resource = ID_AND_CHILDREN .create_resource ({"anchors" : {"foo" : "bar" }})
You can’t perform that action at this time.
0 commit comments