Skip to content

Commit 9582c24

Browse files
committed
Relative IRIs must not have the form of a keyword
1 parent 663b62d commit 9582c24

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/pyld/iri_resolver.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,10 @@ def unresolve(absolute_iri: str, base_iri: str = ""):
260260
# prepend remaining segments
261261
rval += '/'.join(iri_segments)
262262

263+
# relative IRIs must not have the form of a keyword
264+
if rval and rval[0] == '@':
265+
rval = './' + rval
266+
263267
# build relative IRI using urlunparse with empty scheme/netloc
264268
return urlunparse(('', '', rval, '', rel.query or '', rel.fragment or '')) or './'
265269

tests/test_iri_resolver.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,9 @@ def test_base_without_path_slash(self):
316316
def test_base_with_path_slash(self):
317317
assert unresolve('http://base.org/abc/', 'http://base.org') == 'abc/'
318318

319+
def test_absolute_iri_with_keyword(self):
320+
assert unresolve('http://base.org/@abc', 'http://base.org/') == './@abc'
321+
319322
# ---------- Tests for remove_dot_segments() ----------
320323
class TestRemoveDotSegments:
321324
def test_no_slash(self):

0 commit comments

Comments
 (0)