Skip to content

Commit

Permalink
Handle unset rdfDirection the same as null.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlehn committed Sep 7, 2023
1 parent e297249 commit 93e2785
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,10 @@
# jsonld ChangeLog

## 8.3.1 - 2023-09-xx

### Fixed
- Handle unset `rdfDirection` the same as `null`.

## 8.3.0 - 2023-09-06

### Added
Expand Down
4 changes: 2 additions & 2 deletions lib/toRdf.js
Expand Up @@ -330,7 +330,7 @@ function _objectToRDF(
'jsonld.InvalidRdfDirection',
{value: rdfDirection});
} else if('@language' in item) {
if('@direction' in item && rdfDirection === null) {
if('@direction' in item && !rdfDirection) {
if(options.eventHandler) {
// FIXME: only emit once?
_handleEvent({
Expand All @@ -351,7 +351,7 @@ function _objectToRDF(
object.datatype.value = datatype || RDF_LANGSTRING;
object.language = item['@language'];
} else {
if('@direction' in item && rdfDirection === null) {
if('@direction' in item && !rdfDirection) {
if(options.eventHandler) {
// FIXME: only emit once?
_handleEvent({
Expand Down
16 changes: 16 additions & 0 deletions tests/misc.js
Expand Up @@ -4101,6 +4101,22 @@ _:b0 <ex:p> "v" .
});
});

it('should handle no @lang, @dir, no rdfDirection', async () => {
const input = _json_dir_nl_d;
const nq = _nq_dir_nl_nd;

await _test({
type: 'toRDF',
input,
options: {skipExpansion: true},
expected: nq,
eventCodeLog: [
'rdfDirection not set'
],
testNotSafe: true
});
});

it('should handle no @lang, @dir, rdfDirection=null', async () => {
const input = _json_dir_nl_d;
const nq = _nq_dir_nl_nd;
Expand Down

0 comments on commit 93e2785

Please sign in to comment.