Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- When using native types, values of `xsd:boolean` and `xsd:integer` are now properly converted. Fixes [fromRdf#t0027](https://w3c.github.io/json-ld-api/tests/fromRdf-manifest.html#t0027).
- Numbers with 0 as fractional part now parse to an `xsd:integer` instead of `xsd:double`. Fixes [toRdf#ttn02](https://w3c.github.io/json-ld-api/tests/toRdf-manifest.html#ttn02).
- Zeros are now truncated for numeric values with negative exponent.
- Blank node prefixes are now also used in IRI expansion.

## 3.1.0 - 2026-06-19

Expand Down
5 changes: 4 additions & 1 deletion lib/pyld/jsonld.py
Original file line number Diff line number Diff line change
Expand Up @@ -5742,7 +5742,10 @@ def _create_term_definition(
mapping['_prefix'] = (
_simple_term
and not mapping['_term_has_colon']
and bool(re.match(r'.*[:/\?#\[\]@]$', id_))
and (
id_.startswith('_:')
or bool(re.match(r'.*[:/\?#\[\]@]$', id_))
)
)
if '@id' not in mapping:
# see if the term has a prefix
Expand Down
14 changes: 14 additions & 0 deletions tests/test_jsonld.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,20 @@ def test_expand_stringifies_datetime_date_values(self):
'https://schema.org/publicationDate': [{'@value': '2021-01-11'}],
}]

# Issue 167
def test_blank_node_prefixes(self):
"""
Blank nodes as prefix should be used in IRI expansion.
"""
input = {"@context": {"t": "_:b"}, "@type": "t:x"}

expected = [{"@type": ["_:bx"]}]

expanded = jsonld.expand(input)

assert expanded == expected


class TestFrame:
# Issue 11 - PR: https://github.com/digitalbazaar/pyld/issues/149
"""
Expand Down
Loading