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 2
2
Changelog
3
3
=========
4
4
5
+ v0.27.3
6
+ -------
7
+
8
+ * Also strip fragments when using ``__getitem__ `` on URIs with empty fragments.
9
+
5
10
v0.27.2
6
11
-------
7
12
Original file line number Diff line number Diff line change @@ -241,7 +241,7 @@ def __getitem__(self, uri: URI) -> Resource[D]:
241
241
Return the (already crawled) `Resource` identified by the given URI.
242
242
"""
243
243
try :
244
- return self ._resources [uri ]
244
+ return self ._resources [uri . rstrip ( "#" ) ]
245
245
except KeyError :
246
246
raise exceptions .NoSuchResource (ref = uri )
247
247
Original file line number Diff line number Diff line change @@ -155,11 +155,21 @@ def test_contents(self):
155
155
registry = Registry ().with_resource (uri , resource )
156
156
assert registry .contents (uri ) == {"foo" : "bar" }
157
157
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
+
158
164
def test_contents_strips_empty_fragments (self ):
159
165
uri = "http://example.com/"
160
166
resource = ID_AND_CHILDREN .create_resource ({"ID" : uri + "#" })
161
167
registry = resource @ Registry ()
162
- assert registry .contents (uri ) == {"ID" : uri + "#" }
168
+ assert (
169
+ registry .contents (uri )
170
+ == registry .contents (uri + "#" )
171
+ == {"ID" : uri + "#" }
172
+ )
163
173
164
174
def test_crawled_anchor (self ):
165
175
resource = ID_AND_CHILDREN .create_resource ({"anchors" : {"foo" : "bar" }})
You can’t perform that action at this time.
0 commit comments