Skip to content

Commit d2ef05d

Browse files
committed
Avoid _expandIri event during @json type check.
- Add event filter to avoid reletive reference event while expanding to check if a value is `@json`. - Update tests. - Add safe/strict testing flags.
1 parent 0d006f8 commit d2ef05d

File tree

2 files changed

+127
-60
lines changed

2 files changed

+127
-60
lines changed

lib/expand.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,19 @@ async function _expandObject({
527527
const isJsonType = element[typeKey] &&
528528
_expandIri(activeCtx,
529529
(_isArray(element[typeKey]) ? element[typeKey][0] : element[typeKey]),
530-
{vocab: true}, {...options, typeExpansion: true}) === '@json';
530+
{vocab: true}, {
531+
...options,
532+
typeExpansion: true,
533+
eventHandler: [
534+
// filter to avoid relative reference events
535+
({event, next}) => {
536+
if(event.code !== 'relative IRI after expansion') {
537+
next();
538+
}
539+
},
540+
options.eventHandler
541+
]
542+
}) === '@json';
531543

532544
for(const key of keys) {
533545
let value = element[key];

0 commit comments

Comments
 (0)